better error display

This commit is contained in:
Gabriel Fontes
2022-01-28 13:55:52 -03:00
parent 2d364eb6c0
commit 660bb1ae17
4 changed files with 15 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ use serenity::{
async_trait,
client::{Context, EventHandler},
framework::standard::{
macros::{command, group},
macros::{command, group, hook},
Args, CommandResult,
},
model::channel::Message,
@@ -28,6 +28,15 @@ pub struct Handler;
#[async_trait]
impl EventHandler for Handler {}
#[hook]
pub async fn after_hook(ctx: &Context, msg: &Message, cmd_name: &str, error: CommandResult) {
if let Err(why) = error {
let text = format!("Error running {}: {:?}", cmd_name, why);
msg.reply(&ctx.http, &text).await.ok();
eprintln!("{}", &text);
}
}
#[command]
#[aliases(s, p, play)]
/// Play a named song