More clippy::pedantic lints

Use `if let` rather than unnecessary match
This commit is contained in:
Aadi Desai 2023-09-25 23:07:22 +01:00
parent 83db8eb08f
commit ef2be84ae0
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM

View file

@ -614,15 +614,13 @@ 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?;
}
None => {
} else {
let members = db::get_member_by_nickname_fuzzy(&ctx.data().db, &nickname, 3).await?;
if members.is_empty() {
ctx.send(|c| {
@ -643,7 +641,6 @@ pub(crate) async fn whois_by_nickname(ctx: ACtx<'_>, nickname: String) -> Result
.await?;
}
}
}
Ok(())
}
@ -651,15 +648,13 @@ 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?;
}
None => {
} else {
let members = db::get_member_by_realname_fuzzy(&ctx.data().db, &realname, 3).await?;
if members.is_empty() {
ctx.send(|c| {
@ -679,7 +674,6 @@ pub(crate) async fn whois_by_realname(ctx: ACtx<'_>, realname: String) -> Result
})
.await?;
}
}
};
Ok(())
}