Clean up match statements for pinned command

This commit is contained in:
charlotte ✨ 2021-07-07 23:57:30 +01:00
parent 854fb63e48
commit 7c43b9e1cd
1 changed files with 5 additions and 7 deletions

View File

@ -1,5 +1,5 @@
use serenity::{ use serenity::{
framework::standard::{macros::command, Args, CommandResult}, framework::standard::{macros::command, Args, CommandError, CommandResult},
model::{channel::Message, id::ChannelId}, model::{channel::Message, id::ChannelId},
prelude::*, prelude::*,
}; };
@ -19,12 +19,10 @@ async fn pinned(ctx: &Context, message: &Message, mut args: Args) -> CommandResu
Ok(v) => v, Ok(v) => v,
Err(_) => message.channel_id, Err(_) => message.channel_id,
}; };
let pinned = match target_channel.pins(&ctx.http).await { let pinned = target_channel
Ok(v) => v, .pins(&ctx.http)
Err(e) => { .await
return Err(format!("Could not get pinned messages! Error: {}", e).into()); .map_err(|e| CommandError::from(format!("Could not get pinned messages! Error: {}", e)))?;
}
};
if pinned.is_empty() { if pinned.is_empty() {
return Err("No pinned messages found!".into()); return Err("No pinned messages found!".into());
} }