File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -215,10 +215,15 @@ def unselected_options(self) -> Optional[List[Option]]:
215
215
return self .command .options # type: ignore
216
216
return None
217
217
218
+ @property
219
+ def send_modal (self ) -> Interaction :
220
+ """Sends a modal dialog to the user who invoked the interaction."""
221
+ return self .interaction .response .send_modal
222
+
218
223
@property
219
224
def respond (self ) -> Callable [..., Awaitable [Union [Interaction , WebhookMessage ]]]:
220
225
"""Callable[..., Union[:class:`~.Interaction`, :class:`~.Webhook`]]: Sends either a response
221
- or a followup response depending if the interaction has been responded to yet or not."""
226
+ or a followup response depending on if the interaction has been responded to yet or not."""
222
227
if not self .interaction .response .is_done ():
223
228
return self .interaction .response .send_message # self.response
224
229
else :
Original file line number Diff line number Diff line change @@ -792,7 +792,7 @@ async def send_autocomplete_result(
792
792
793
793
self ._responded = True
794
794
795
- async def send_modal (self , modal : Modal ):
795
+ async def send_modal (self , modal : Modal ) -> Interaction :
796
796
"""|coro|
797
797
Responds to this interaction by sending a modal dialog.
798
798
This cannot be used to respond to another modal dialog submission.
@@ -823,6 +823,7 @@ async def send_modal(self, modal: Modal):
823
823
)
824
824
self ._responded = True
825
825
self ._parent ._state .store_modal (modal , self ._parent .user .id )
826
+ return self ._parent
826
827
827
828
828
829
class _InteractionMessageState :
Original file line number Diff line number Diff line change @@ -35,23 +35,23 @@ async def callback(self, interaction: discord.Interaction):
35
35
async def modal_slash (ctx ):
36
36
"""Shows an example of a modal dialog being invoked from a slash command."""
37
37
modal = MyModal (title = "Slash Command Modal" )
38
- await ctx .interaction . response . send_modal (modal )
38
+ await ctx .send_modal (modal )
39
39
40
40
41
41
@bot .message_command (name = "messagemodal" , guild_ids = [...])
42
42
async def modal_message (ctx , message ):
43
43
"""Shows an example of a modal dialog being invoked from a message command."""
44
44
modal = MyModal (title = "Message Command Modal" )
45
45
modal .title = f"Modal for Message ID: { message .id } "
46
- await ctx .interaction . response . send_modal (modal )
46
+ await ctx .send_modal (modal )
47
47
48
48
49
49
@bot .user_command (name = "usermodal" , guild_ids = [...])
50
50
async def modal_user (ctx , member ):
51
51
"""Shows an example of a modal dialog being invoked from a user command."""
52
52
modal = MyModal (title = "User Command Modal" )
53
53
modal .title = f"Modal for User: { member .display_name } "
54
- await ctx .interaction . response . send_modal (modal )
54
+ await ctx .send_modal (modal )
55
55
56
56
57
57
@bot .command ()
You can’t perform that action at this time.
0 commit comments