File tree Expand file tree Collapse file tree 4 files changed +23
-8
lines changed Expand file tree Collapse file tree 4 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -50,13 +50,18 @@ pub(crate) async fn dispatch_model(
5050 #[ cfg( feature = "framework" ) ] framework : Option < Arc < dyn Framework > > ,
5151 event_handler : Option < InternalEventHandler > ,
5252) {
53- let handler = match event_handler {
54- Some ( InternalEventHandler :: Normal ( handler) ) => Some ( handler) ,
55- Some ( InternalEventHandler :: Raw ( raw_handler) ) => {
56- return raw_handler. raw_event ( context, event) . await ;
57- } ,
58- None => None ,
53+ let ( handler, raw_handler) = match event_handler {
54+ Some ( InternalEventHandler :: Normal ( handler) ) => ( Some ( handler) , None ) ,
55+ Some ( InternalEventHandler :: Both {
56+ raw,
57+ normal,
58+ } ) => ( Some ( normal) , Some ( raw) ) ,
59+ Some ( InternalEventHandler :: Raw ( raw_handler) ) => ( None , Some ( raw_handler) ) ,
60+ None => ( None , None ) ,
5961 } ;
62+ if let Some ( raw_handler) = raw_handler {
63+ raw_handler. raw_event ( context. clone ( ) , & event) . await ;
64+ }
6065
6166 let ( full_event, extra_event) = update_cache_with_event (
6267 #[ cfg( feature = "cache" ) ]
Original file line number Diff line number Diff line change @@ -513,7 +513,7 @@ event_handler! {
513513#[ async_trait]
514514pub trait RawEventHandler : Send + Sync {
515515 /// Dispatched when any event occurs
516- async fn raw_event ( & self , _ctx : Context , _ev : Event ) { }
516+ async fn raw_event ( & self , _ctx : Context , _ev : & Event ) { }
517517
518518 /// Checks if the `event` should be dispatched (`true`) or ignored (`false`).
519519 ///
@@ -540,4 +540,5 @@ pub trait RawEventHandler: Send + Sync {
540540pub enum InternalEventHandler {
541541 Raw ( Arc < dyn RawEventHandler > ) ,
542542 Normal ( Arc < dyn EventHandler > ) ,
543+ Both { raw : Arc < dyn RawEventHandler > , normal : Arc < dyn EventHandler > } ,
543544}
Original file line number Diff line number Diff line change @@ -296,7 +296,10 @@ impl IntoFuture for ClientBuilder {
296296 let http = self . http ;
297297
298298 let event_handler = match ( self . event_handler , self . raw_event_handler ) {
299- ( Some ( _) , Some ( _) ) => panic ! ( "Cannot provide both a normal and raw event handlers" ) ,
299+ ( Some ( normal) , Some ( raw) ) => Some ( InternalEventHandler :: Both {
300+ normal,
301+ raw,
302+ } ) ,
300303 ( Some ( h) , None ) => Some ( InternalEventHandler :: Normal ( h) ) ,
301304 ( None , Some ( h) ) => Some ( InternalEventHandler :: Raw ( h) ) ,
302305 ( None , None ) => None ,
Original file line number Diff line number Diff line change @@ -178,6 +178,12 @@ impl ShardRunner {
178178 Some ( InternalEventHandler :: Raw ( handler) ) => {
179179 handler. filter_event ( & context, & event)
180180 } ,
181+ Some ( InternalEventHandler :: Both {
182+ raw,
183+ normal,
184+ } ) => {
185+ raw. filter_event ( & context, & event) && normal. filter_event ( & context, & event)
186+ } ,
181187 None => true ,
182188 } ;
183189
You can’t perform that action at this time.
0 commit comments