mirror of
https://github.com/supleed2/nanobot.git
synced 2025-01-06 21:32:00 +00:00
More clippy::pedantic
lints
Use `if let` rather than unnecessary match
This commit is contained in:
parent
83db8eb08f
commit
ef2be84ae0
14
src/cmds.rs
14
src/cmds.rs
|
@ -614,15 +614,13 @@ pub(crate) async fn whois_by_id(ctx: ACtx<'_>, id: serenity::User) -> Result<(),
|
||||||
#[poise::command(slash_command, rename = "nick")]
|
#[poise::command(slash_command, rename = "nick")]
|
||||||
pub(crate) async fn whois_by_nickname(ctx: ACtx<'_>, nickname: String) -> Result<(), Error> {
|
pub(crate) async fn whois_by_nickname(ctx: ACtx<'_>, nickname: String) -> Result<(), Error> {
|
||||||
println!("Cmd: ({}) whois_by_nickname {nickname}", ctx.author().name);
|
println!("Cmd: ({}) whois_by_nickname {nickname}", ctx.author().name);
|
||||||
match db::get_member_by_nickname(&ctx.data().db, &nickname).await? {
|
if let Some(m) = db::get_member_by_nickname(&ctx.data().db, &nickname).await? {
|
||||||
Some(m) => {
|
|
||||||
ctx.send(|c| {
|
ctx.send(|c| {
|
||||||
c.content(format!("{nickname}: <@{}>", m.discord_id))
|
c.content(format!("{nickname}: <@{}>", m.discord_id))
|
||||||
.ephemeral(true)
|
.ephemeral(true)
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
}
|
} else {
|
||||||
None => {
|
|
||||||
let members = db::get_member_by_nickname_fuzzy(&ctx.data().db, &nickname, 3).await?;
|
let members = db::get_member_by_nickname_fuzzy(&ctx.data().db, &nickname, 3).await?;
|
||||||
if members.is_empty() {
|
if members.is_empty() {
|
||||||
ctx.send(|c| {
|
ctx.send(|c| {
|
||||||
|
@ -643,7 +641,6 @@ pub(crate) async fn whois_by_nickname(ctx: ACtx<'_>, nickname: String) -> Result
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,15 +648,13 @@ pub(crate) async fn whois_by_nickname(ctx: ACtx<'_>, nickname: String) -> Result
|
||||||
#[poise::command(slash_command, rename = "name")]
|
#[poise::command(slash_command, rename = "name")]
|
||||||
pub(crate) async fn whois_by_realname(ctx: ACtx<'_>, realname: String) -> Result<(), Error> {
|
pub(crate) async fn whois_by_realname(ctx: ACtx<'_>, realname: String) -> Result<(), Error> {
|
||||||
println!("Cmd: ({}) whois_by_realname {realname}", ctx.author().name);
|
println!("Cmd: ({}) whois_by_realname {realname}", ctx.author().name);
|
||||||
match db::get_member_by_realname(&ctx.data().db, &realname).await? {
|
if let Some(m) = db::get_member_by_realname(&ctx.data().db, &realname).await? {
|
||||||
Some(m) => {
|
|
||||||
ctx.send(|c| {
|
ctx.send(|c| {
|
||||||
c.content(format!("{realname}: <@{}>", m.discord_id))
|
c.content(format!("{realname}: <@{}>", m.discord_id))
|
||||||
.ephemeral(true)
|
.ephemeral(true)
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
}
|
} else {
|
||||||
None => {
|
|
||||||
let members = db::get_member_by_realname_fuzzy(&ctx.data().db, &realname, 3).await?;
|
let members = db::get_member_by_realname_fuzzy(&ctx.data().db, &realname, 3).await?;
|
||||||
if members.is_empty() {
|
if members.is_empty() {
|
||||||
ctx.send(|c| {
|
ctx.send(|c| {
|
||||||
|
@ -679,7 +674,6 @@ pub(crate) async fn whois_by_realname(ctx: ACtx<'_>, realname: String) -> Result
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue