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