Switch 'match' to 'if let' in main.rs::after
This lets us drop a level of indentation, and remove the clunky match arm for Ok(()) => () :)
This commit is contained in:
parent
4eb78cd75a
commit
aecdc7a273
43
src/main.rs
43
src/main.rs
|
@ -91,30 +91,27 @@ async fn dispatch_error(ctx: &Context, msg: &Message, error: DispatchError) {
|
||||||
#[hook]
|
#[hook]
|
||||||
async fn after(ctx: &Context, msg: &Message, command_name: &str, command_result: CommandResult) {
|
async fn after(ctx: &Context, msg: &Message, command_name: &str, command_result: CommandResult) {
|
||||||
// prints error in chat
|
// prints error in chat
|
||||||
match command_result {
|
if let Err(why) = command_result {
|
||||||
Ok(()) => (),
|
let _ = msg
|
||||||
Err(why) => {
|
.channel_id
|
||||||
let _ = msg
|
.send_message(&ctx.http, |m| {
|
||||||
.channel_id
|
m.embed(|e| {
|
||||||
.send_message(&ctx.http, |m| {
|
e.title(format!("Error in **{}**", command_name))
|
||||||
m.embed(|e| {
|
.description(&why.to_string())
|
||||||
e.title(format!("Error in **{}**", command_name))
|
/*.thumbnail("https://i.imgur.com/VzOEz2E.png") oh no */
|
||||||
.description(&why.to_string())
|
.colour(0xff6961)
|
||||||
/*.thumbnail("https://i.imgur.com/VzOEz2E.png") oh no */
|
|
||||||
.colour(0xff6961)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.await;
|
})
|
||||||
// prints error in console
|
.await;
|
||||||
eprintln!(
|
// prints error in console
|
||||||
"{}",
|
eprintln!(
|
||||||
format!(
|
"{}",
|
||||||
"Error in {}: {}",
|
format!(
|
||||||
command_name.purple(),
|
"Error in {}: {}",
|
||||||
&why.to_string().red().bold()
|
command_name.purple(),
|
||||||
)
|
&why.to_string().red().bold()
|
||||||
);
|
)
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue