Replace match-return with try operator on map_err in spoile.rs::spoiler

This commit is contained in:
charlotte ✨ 2021-07-07 18:55:28 +01:00
parent f89eb2842c
commit a02bcecb5b
1 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
use serenity::{
builder::CreateMessage,
framework::standard::{macros::command, Args, CommandResult},
framework::standard::{macros::command, Args, CommandError, CommandResult},
http::AttachmentType,
model::channel::Message,
prelude::*,
@ -42,10 +42,10 @@ async fn spoiler(ctx: &Context, message: &Message, args: Args) -> CommandResult
for a in attachments {
// download each attachment
let content = match a.download().await {
Ok(content) => content,
Err(_) => return Err("Error downloading attachment".into()),
};
let content = a
.download()
.await
.map_err(|_| CommandError::from("Error downloading attachment"))?;
let content: &[u8] = content.as_slice();