mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-06 01:51:59 +00:00
Allow deferring modal_submit interactions
This also adds a thinking boolean to toggle which type of deferring is done when there can be ambiguity.
This commit is contained in:
parent
19c6687b55
commit
af8e74d327
@ -286,7 +286,7 @@ class Interaction:
|
|||||||
attachments: List[Union[:class:`Attachment`, :class:`File`]]
|
attachments: List[Union[:class:`Attachment`, :class:`File`]]
|
||||||
A list of attachments to keep in the message as well as new files to upload. If ``[]`` is passed
|
A list of attachments to keep in the message as well as new files to upload. If ``[]`` is passed
|
||||||
then all attachments are removed.
|
then all attachments are removed.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
New files will always appear after current attachments.
|
New files will always appear after current attachments.
|
||||||
@ -388,7 +388,7 @@ class InteractionResponse:
|
|||||||
"""
|
"""
|
||||||
return self._responded
|
return self._responded
|
||||||
|
|
||||||
async def defer(self, *, ephemeral: bool = False) -> None:
|
async def defer(self, *, ephemeral: bool = False, thinking: bool = False) -> None:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
Defers the interaction response.
|
Defers the interaction response.
|
||||||
@ -396,11 +396,23 @@ class InteractionResponse:
|
|||||||
This is typically used when the interaction is acknowledged
|
This is typically used when the interaction is acknowledged
|
||||||
and a secondary action will be done later.
|
and a secondary action will be done later.
|
||||||
|
|
||||||
|
This is only supported with the following interaction types:
|
||||||
|
|
||||||
|
- :attr:`InteractionType.application_command`
|
||||||
|
- :attr:`InteractionType.component`
|
||||||
|
- :attr:`InteractionType.modal_submit`
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
-----------
|
-----------
|
||||||
ephemeral: :class:`bool`
|
ephemeral: :class:`bool`
|
||||||
Indicates whether the deferred message will eventually be ephemeral.
|
Indicates whether the deferred message will eventually be ephemeral.
|
||||||
This only applies for interactions of type :attr:`InteractionType.application_command`.
|
This only applies for interactions of type :attr:`InteractionType.application_command`.
|
||||||
|
thinking: :class:`bool`
|
||||||
|
Indicates whether the deferred type should be :attr:`InteractionResponseType.deferred_channel_message`
|
||||||
|
instead of the default :attr:`InteractionResponseType.deferred_message_update` if both are valid.
|
||||||
|
In UI terms, this is represented as if the bot is thinking of a response. It is your responsibility to
|
||||||
|
eventually send a followup message via :attr:`Interaction.followup` to make this thinking state go away.
|
||||||
|
Application commands (AKA Slash commands) cannot use :attr:`InteractionResponseType.deferred_message_update`.
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
-------
|
-------
|
||||||
@ -415,8 +427,12 @@ class InteractionResponse:
|
|||||||
defer_type: int = 0
|
defer_type: int = 0
|
||||||
data: Optional[Dict[str, Any]] = None
|
data: Optional[Dict[str, Any]] = None
|
||||||
parent = self._parent
|
parent = self._parent
|
||||||
if parent.type is InteractionType.component:
|
if parent.type is InteractionType.component or parent.type is InteractionType.modal_submit:
|
||||||
defer_type = InteractionResponseType.deferred_message_update.value
|
defer_type = (
|
||||||
|
InteractionResponseType.deferred_channel_message.value
|
||||||
|
if thinking
|
||||||
|
else InteractionResponseType.deferred_message_update.value
|
||||||
|
)
|
||||||
elif parent.type is InteractionType.application_command:
|
elif parent.type is InteractionType.application_command:
|
||||||
defer_type = InteractionResponseType.deferred_channel_message.value
|
defer_type = InteractionResponseType.deferred_channel_message.value
|
||||||
if ephemeral:
|
if ephemeral:
|
||||||
@ -572,7 +588,7 @@ class InteractionResponse:
|
|||||||
attachments: List[Union[:class:`Attachment`, :class:`File`]]
|
attachments: List[Union[:class:`Attachment`, :class:`File`]]
|
||||||
A list of attachments to keep in the message as well as new files to upload. If ``[]`` is passed
|
A list of attachments to keep in the message as well as new files to upload. If ``[]`` is passed
|
||||||
then all attachments are removed.
|
then all attachments are removed.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
New files will always appear after current attachments.
|
New files will always appear after current attachments.
|
||||||
@ -660,7 +676,7 @@ class InteractionResponse:
|
|||||||
session=parent._session,
|
session=parent._session,
|
||||||
params=params,
|
params=params,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._parent._state.store_view(modal)
|
self._parent._state.store_view(modal)
|
||||||
self._responded = True
|
self._responded = True
|
||||||
|
|
||||||
@ -729,7 +745,7 @@ class InteractionMessage(Message):
|
|||||||
attachments: List[Union[:class:`Attachment`, :class:`File`]]
|
attachments: List[Union[:class:`Attachment`, :class:`File`]]
|
||||||
A list of attachments to keep in the message as well as new files to upload. If ``[]`` is passed
|
A list of attachments to keep in the message as well as new files to upload. If ``[]`` is passed
|
||||||
then all attachments are removed.
|
then all attachments are removed.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
New files will always appear after current attachments.
|
New files will always appear after current attachments.
|
||||||
@ -765,7 +781,7 @@ class InteractionMessage(Message):
|
|||||||
view=view,
|
view=view,
|
||||||
allowed_mentions=allowed_mentions,
|
allowed_mentions=allowed_mentions,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def add_files(self, *files: File) -> InteractionMessage:
|
async def add_files(self, *files: File) -> InteractionMessage:
|
||||||
r"""|coro|
|
r"""|coro|
|
||||||
|
|
||||||
@ -784,7 +800,7 @@ class InteractionMessage(Message):
|
|||||||
Editing the message failed.
|
Editing the message failed.
|
||||||
Forbidden
|
Forbidden
|
||||||
Tried to edit a message that isn't yours.
|
Tried to edit a message that isn't yours.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
---------
|
---------
|
||||||
:class:`InteractionMessage`
|
:class:`InteractionMessage`
|
||||||
@ -803,7 +819,7 @@ class InteractionMessage(Message):
|
|||||||
-----------
|
-----------
|
||||||
\*attachments: :class:`Attachment`
|
\*attachments: :class:`Attachment`
|
||||||
Attachments to remove from the message.
|
Attachments to remove from the message.
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
-------
|
-------
|
||||||
HTTPException
|
HTTPException
|
||||||
|
Loading…
x
Reference in New Issue
Block a user