From ef52b11b296c1b32a64ece838d218fa0503ae6ae Mon Sep 17 00:00:00 2001 From: David Thomas Date: Sun, 26 Nov 2023 21:02:39 +0000 Subject: [PATCH] Revert signature of dispatch --- src/client/dispatch.rs | 2 +- src/client/event_handler.rs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs index 362fd600f85..f72e5403c46 100644 --- a/src/client/dispatch.rs +++ b/src/client/dispatch.rs @@ -67,7 +67,7 @@ pub(crate) fn dispatch_model( let context = context.clone(); let handler = Arc::clone(&handler); spawn_named(event.snake_case_name(), async move { - event.dispatch(&*handler, Some(context)).await; + event.dispatch(context, &*handler).await; }); } } diff --git a/src/client/event_handler.rs b/src/client/event_handler.rs index b99050f189a..01241a2de7d 100644 --- a/src/client/event_handler.rs +++ b/src/client/event_handler.rs @@ -62,13 +62,11 @@ macro_rules! event_handler { /// /// # Panics /// Panics if the event requires [`Context`] and `ctx` is None. - pub async fn dispatch(self, handler: &dyn EventHandler, ctx: Option) { + pub async fn dispatch(self, ctx: Context, handler: &dyn EventHandler) { match self { $( $( #[cfg(feature = $feature)] )? Self::$variant_name { $( $arg_name ),* } => { - $(let Some($context) = ctx else { - panic!("Missing Context for dispatch call!"); - };)? + $( let $context = ctx; )? handler.$method_name($($context,)? $( $arg_name ),* ).await; } )* }