11//! Modal trait and utility items for implementing it (mainly for the derive macro)
22
3+ use std:: future:: Future ;
4+
35use crate :: serenity_prelude as serenity;
46
57/// Meant for use in derived [`Modal::parse`] implementation
@@ -40,10 +42,7 @@ pub fn find_modal_text(
4042
4143/// Underlying code for the modal spawning convenience function which abstracts over the kind of
4244/// interaction
43- async fn execute_modal_generic <
44- M : Modal ,
45- F : std:: future:: Future < Output = Result < ( ) , serenity:: Error > > ,
46- > (
45+ async fn execute_modal_generic < M : Modal , F : Future < Output = Result < ( ) , serenity:: Error > > > (
4746 ctx : & serenity:: Context ,
4847 create_interaction_response : impl FnOnce ( serenity:: CreateInteractionResponse ) -> F ,
4948 modal_custom_id : String ,
@@ -169,7 +168,6 @@ pub async fn execute_modal_on_component_interaction<M: Modal>(
169168/// Ok(())
170169/// }
171170/// ```
172- #[ async_trait:: async_trait]
173171pub trait Modal : Sized {
174172 /// Returns an interaction response builder which creates the modal for this type
175173 ///
@@ -187,18 +185,24 @@ pub trait Modal: Sized {
187185 ///
188186 /// For a variant that is triggered on component interactions, see [`execute_modal_on_component_interaction`].
189187 // TODO: add execute_with_defaults? Or add a `defaults: Option<Self>` param?
190- async fn execute < U : Send + Sync , E > (
188+ fn execute < U : Send + Sync , E > (
191189 ctx : crate :: ApplicationContext < ' _ , U , E > ,
192- ) -> Result < Option < Self > , serenity:: Error > {
193- execute_modal ( ctx, None :: < Self > , None ) . await
190+ ) -> impl Future < Output = Result < Option < Self > , serenity:: Error > > + Send
191+ where
192+ Self : Send ,
193+ {
194+ execute_modal ( ctx, None :: < Self > , None )
194195 }
195196
196197 /// Calls `execute_modal(ctx, Some(defaults), None)`. See [`execute_modal`]
197198 // TODO: deprecate this in favor of execute_modal()?
198- async fn execute_with_defaults < U : Send + Sync , E > (
199+ fn execute_with_defaults < U : Send + Sync , E > (
199200 ctx : crate :: ApplicationContext < ' _ , U , E > ,
200201 defaults : Self ,
201- ) -> Result < Option < Self > , serenity:: Error > {
202- execute_modal ( ctx, Some ( defaults) , None ) . await
202+ ) -> impl Future < Output = Result < Option < Self > , serenity:: Error > > + Send
203+ where
204+ Self : Send ,
205+ {
206+ execute_modal ( ctx, Some ( defaults) , None )
203207 }
204208}
0 commit comments