1+ mod quick_modal;
2+
13use std:: sync:: Arc ;
24
35use futures:: future:: pending;
46use futures:: { Stream , StreamExt as _} ;
7+ pub use quick_modal:: * ;
58
69use crate :: gateway:: { CollectorCallback , ShardMessenger } ;
710use crate :: internal:: prelude:: * ;
@@ -51,6 +54,7 @@ macro_rules! make_specific_collector {
5154 (
5255 $( #[ $( $meta: tt) * ] ) *
5356 $collector_type: ident, $item_type: ident,
57+ $collector_trait: ident, $method_name: ident,
5458 $extractor: pat => $extracted_item: ident,
5559 $( $filter_name: ident: $filter_type: ty => $filter_passes: expr, ) *
5660 ) => {
@@ -100,7 +104,7 @@ macro_rules! make_specific_collector {
100104 let filters_pass = move |$extracted_item: & $item_type| {
101105 // Check each of the built-in filters (author_id, channel_id, etc.)
102106 $( if let Some ( $filter_name) = & self . $filter_name {
103- if !$filter_passes {
107+ if !( $filter_passes) {
104108 return false ;
105109 }
106110 } ) *
@@ -142,12 +146,27 @@ macro_rules! make_specific_collector {
142146 Box :: pin( self . next( ) )
143147 }
144148 }
149+
150+ pub trait $collector_trait {
151+ fn $method_name( self , shard_messenger: ShardMessenger ) -> $collector_type;
152+ }
153+
154+ $(
155+ impl $collector_trait for $filter_type {
156+ fn $method_name( self , shard_messenger: ShardMessenger ) -> $collector_type {
157+ $collector_type:: new( shard_messenger) . $filter_name( self )
158+ }
159+ }
160+ ) *
145161 } ;
146162}
147163
148164make_specific_collector ! (
149165 // First line has name of the collector type, and the type of the collected items.
150166 ComponentInteractionCollector , ComponentInteraction ,
167+ // Second line has name of the specific trait and method name that will be
168+ // implemented on the filter argument types listed below.
169+ CollectComponentInteractions , collect_component_interactions,
151170 // This defines the extractor pattern, which extracts the data we want to collect from an Event.
152171 Event :: InteractionCreate ( InteractionCreateEvent {
153172 interaction: Interaction :: Component ( interaction) ,
@@ -165,6 +184,7 @@ make_specific_collector!(
165184) ;
166185make_specific_collector ! (
167186 ModalInteractionCollector , ModalInteraction ,
187+ CollectModalInteractions , collect_modal_interactions,
168188 Event :: InteractionCreate ( InteractionCreateEvent {
169189 interaction: Interaction :: Modal ( interaction) ,
170190 } ) => interaction,
@@ -176,6 +196,7 @@ make_specific_collector!(
176196) ;
177197make_specific_collector ! (
178198 ReactionCollector , Reaction ,
199+ CollectReactions , collect_reactions,
179200 Event :: ReactionAdd ( ReactionAddEvent { reaction } ) => reaction,
180201 author_id: UserId => reaction. user_id. map_or( true , |a| a == * author_id) ,
181202 channel_id: ChannelId => reaction. channel_id == * channel_id,
@@ -184,6 +205,7 @@ make_specific_collector!(
184205) ;
185206make_specific_collector ! (
186207 MessageCollector , Message ,
208+ CollectMessages , collect_messages,
187209 Event :: MessageCreate ( MessageCreateEvent { message } ) => message,
188210 author_id: UserId => message. author. id == * author_id,
189211 channel_id: ChannelId => message. channel_id == * channel_id,
0 commit comments