Replace match-return with try operator on map_err in spoile.rs::spoiler
This commit is contained in:
parent
f89eb2842c
commit
a02bcecb5b
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue