@@ -21,9 +21,38 @@ type Context<'a> = poise::Context<'a, Data, Error>;
2121async fn on_error ( error : poise:: FrameworkError < ' _ , Data , Error > ) {
2222 match error {
2323 poise:: FrameworkError :: Setup { error, .. } => panic ! ( "Failed to start bot: {:?}" , error) ,
24- poise:: FrameworkError :: Command { error, ctx, .. } => {
25- println ! ( "Error in command `{}`: {:?}" , ctx. command( ) . name, error, ) ;
24+ poise:: FrameworkError :: Command { ctx, error, .. } => {
25+ let error = error. to_string ( ) ;
26+ eprintln ! ( "An error occured in a command: {}" , error) ;
27+ commands:: respond_err ( & ctx, "Command Error" , & error) . await ;
2628 }
29+
30+ poise:: FrameworkError :: ArgumentParse {
31+ error, input, ctx, ..
32+ } => {
33+ let usage = match & ctx. command ( ) . help_text {
34+ Some ( help_text) => & * * help_text,
35+ None => "Please check the help menu for usage information" ,
36+ } ;
37+ let response = if let Some ( input) = input {
38+ format ! (
39+ "**Cannot parse `{}` as argument: {}**\n {}" ,
40+ input, error, usage
41+ )
42+ } else {
43+ format ! ( "### {}\n {}" , error, usage)
44+ } ;
45+ commands:: respond_err ( & ctx, "Argument Parsing Error" , & response) . await ;
46+ }
47+ poise:: FrameworkError :: GuildOnly { ctx, .. } => {
48+ commands:: respond_err (
49+ & ctx,
50+ "This command cannot be ran in DMs." ,
51+ "You cannot run this command in DMs." ,
52+ )
53+ . await ;
54+ }
55+
2756 error => {
2857 if let Err ( e) = poise:: builtins:: on_error ( error) . await {
2958 println ! ( "Error while handling error: {}" , e)
0 commit comments