Skip to content

Commit

Permalink
Revert signature of dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Nov 26, 2023
1 parent 287739a commit ef52b11
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/client/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/client/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Context>) {
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;
}
)* }
Expand Down

0 comments on commit ef52b11

Please sign in to comment.