File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ use std::sync::Arc;
1111use std:: time:: Duration ;
1212
1313use poise:: serenity_prelude:: { Client , GatewayIntents } ;
14- use poise:: { Framework , FrameworkOptions } ;
14+ use poise:: { CreateReply , Framework , FrameworkOptions } ;
1515
1616pub use crate :: config:: Config ;
1717pub use crate :: message:: Message ;
@@ -42,6 +42,28 @@ pub async fn build_bot() -> anyhow::Result<()> {
4242 event_handler : |ctx, event, framework, data| {
4343 Box :: pin ( event_handler:: event_handler ( ctx, event, framework, data) )
4444 } ,
45+ on_error : |error| {
46+ Box :: pin ( async move {
47+ if let poise:: FrameworkError :: Command { ctx, .. } = error {
48+ let _ = ctx
49+ . send (
50+ CreateReply :: default ( )
51+ . content ( Message :: Error )
52+ . ephemeral ( true ) ,
53+ )
54+ . await ;
55+
56+ return ;
57+ }
58+
59+ if let poise:: FrameworkError :: Setup { error, .. } = error {
60+ tracing:: error!( "Framework setup error: {:?}" , error) ;
61+ return ;
62+ }
63+
64+ tracing:: error!( "Other framework error (no user context to reply to)." ) ;
65+ } )
66+ } ,
4567 ..Default :: default ( )
4668 } ;
4769
You can’t perform that action at this time.
0 commit comments