mirror of
https://github.com/supleed2/nanobot.git
synced 2024-12-22 06:05:50 +00:00
More clippy::pedantic
lints
Use `if let` rather than unnecessary match
This commit is contained in:
parent
83db8eb08f
commit
ef2be84ae0
90
src/cmds.rs
90
src/cmds.rs
|
@ -614,34 +614,31 @@ pub(crate) async fn whois_by_id(ctx: ACtx<'_>, id: serenity::User) -> Result<(),
|
|||
#[poise::command(slash_command, rename = "nick")]
|
||||
pub(crate) async fn whois_by_nickname(ctx: ACtx<'_>, nickname: String) -> Result<(), Error> {
|
||||
println!("Cmd: ({}) whois_by_nickname {nickname}", ctx.author().name);
|
||||
match db::get_member_by_nickname(&ctx.data().db, &nickname).await? {
|
||||
Some(m) => {
|
||||
if let Some(m) = db::get_member_by_nickname(&ctx.data().db, &nickname).await? {
|
||||
ctx.send(|c| {
|
||||
c.content(format!("{nickname}: <@{}>", m.discord_id))
|
||||
.ephemeral(true)
|
||||
})
|
||||
.await?;
|
||||
} else {
|
||||
let members = db::get_member_by_nickname_fuzzy(&ctx.data().db, &nickname, 3).await?;
|
||||
if members.is_empty() {
|
||||
ctx.send(|c| {
|
||||
c.content(format!("{nickname}: <@{}>", m.discord_id))
|
||||
c.content(format!("No member entry found for nickname {nickname}"))
|
||||
.ephemeral(true)
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
None => {
|
||||
let members = db::get_member_by_nickname_fuzzy(&ctx.data().db, &nickname, 3).await?;
|
||||
if members.is_empty() {
|
||||
ctx.send(|c| {
|
||||
c.content(format!("No member entry found for nickname {nickname}"))
|
||||
.ephemeral(true)
|
||||
})
|
||||
.await?;
|
||||
} else {
|
||||
ctx.send(|c| {
|
||||
c.ephemeral(true).content(format!(
|
||||
"Possible matches for {nickname}: {}",
|
||||
members
|
||||
.iter()
|
||||
.map(|m| format!(" <@{}>", m.discord_id))
|
||||
.collect::<String>()
|
||||
))
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
} else {
|
||||
ctx.send(|c| {
|
||||
c.ephemeral(true).content(format!(
|
||||
"Possible matches for {nickname}: {}",
|
||||
members
|
||||
.iter()
|
||||
.map(|m| format!(" <@{}>", m.discord_id))
|
||||
.collect::<String>()
|
||||
))
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -651,34 +648,31 @@ pub(crate) async fn whois_by_nickname(ctx: ACtx<'_>, nickname: String) -> Result
|
|||
#[poise::command(slash_command, rename = "name")]
|
||||
pub(crate) async fn whois_by_realname(ctx: ACtx<'_>, realname: String) -> Result<(), Error> {
|
||||
println!("Cmd: ({}) whois_by_realname {realname}", ctx.author().name);
|
||||
match db::get_member_by_realname(&ctx.data().db, &realname).await? {
|
||||
Some(m) => {
|
||||
if let Some(m) = db::get_member_by_realname(&ctx.data().db, &realname).await? {
|
||||
ctx.send(|c| {
|
||||
c.content(format!("{realname}: <@{}>", m.discord_id))
|
||||
.ephemeral(true)
|
||||
})
|
||||
.await?;
|
||||
} else {
|
||||
let members = db::get_member_by_realname_fuzzy(&ctx.data().db, &realname, 3).await?;
|
||||
if members.is_empty() {
|
||||
ctx.send(|c| {
|
||||
c.content(format!("{realname}: <@{}>", m.discord_id))
|
||||
c.content(format!("No member entry found for realname {realname}"))
|
||||
.ephemeral(true)
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
None => {
|
||||
let members = db::get_member_by_realname_fuzzy(&ctx.data().db, &realname, 3).await?;
|
||||
if members.is_empty() {
|
||||
ctx.send(|c| {
|
||||
c.content(format!("No member entry found for realname {realname}"))
|
||||
.ephemeral(true)
|
||||
})
|
||||
.await?;
|
||||
} else {
|
||||
ctx.send(|c| {
|
||||
c.ephemeral(true).content(format!(
|
||||
"Possible matches for {realname}: {}",
|
||||
members
|
||||
.iter()
|
||||
.map(|m| format!(" <@{}>", m.discord_id))
|
||||
.collect::<String>()
|
||||
))
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
} else {
|
||||
ctx.send(|c| {
|
||||
c.ephemeral(true).content(format!(
|
||||
"Possible matches for {realname}: {}",
|
||||
members
|
||||
.iter()
|
||||
.map(|m| format!(" <@{}>", m.discord_id))
|
||||
.collect::<String>()
|
||||
))
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue