Improve error reporting

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/2/head
trivernis 4 years ago
parent dd5c9a3673
commit 7dc8087dac
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,10 +1,10 @@
use serenity::async_trait; use serenity::async_trait;
use serenity::client::{Context, EventHandler}; use serenity::client::{Context, EventHandler};
use serenity::Client;
use serenity::framework::standard::{CommandResult, DispatchError};
use serenity::framework::standard::macros::hook; use serenity::framework::standard::macros::hook;
use serenity::framework::standard::{CommandResult, DispatchError};
use serenity::framework::StandardFramework; use serenity::framework::StandardFramework;
use serenity::model::channel::Message; use serenity::model::channel::Message;
use serenity::Client;
use songbird::SerenityInit; use songbird::SerenityInit;
use crate::commands::*; use crate::commands::*;
@ -58,7 +58,15 @@ pub fn get_framework() -> StandardFramework {
async fn after_hook(ctx: &Context, msg: &Message, cmd_name: &str, error: CommandResult) { async fn after_hook(ctx: &Context, msg: &Message, cmd_name: &str, error: CommandResult) {
// Print out an error if it happened // Print out an error if it happened
if let Err(why) = error { if let Err(why) = error {
let _ = msg.channel_id.say(&ctx, format!("{}", why)).await; let _ = msg
.channel_id
.send_message(ctx, |m| {
m.embed(|e| {
e.title("Error occurred")
.description(format!("```\n{}\n```", why))
})
})
.await;
println!("Error in {}: {:?}", cmd_name, why); println!("Error in {}: {:?}", cmd_name, why);
} }
} }

Loading…
Cancel
Save