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