diff --git a/src/commands/pinned.rs b/src/commands/pinned.rs index c73d93d..e57b49d 100644 --- a/src/commands/pinned.rs +++ b/src/commands/pinned.rs @@ -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()); }