mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-12-03 14:02:19 +00:00
Add support for Modal Interactions
This commit is contained in:
@@ -60,6 +60,7 @@ if TYPE_CHECKING:
|
||||
from aiohttp import ClientSession
|
||||
from .embeds import Embed
|
||||
from .ui.view import View
|
||||
from .ui.modal import Modal
|
||||
from .channel import VoiceChannel, StageChannel, TextChannel, CategoryChannel, StoreChannel, PartialMessageable
|
||||
from .threads import Thread
|
||||
|
||||
@@ -628,6 +629,41 @@ class InteractionResponse:
|
||||
|
||||
self._responded = True
|
||||
|
||||
async def send_modal(self, modal: Modal, /):
|
||||
"""|coro|
|
||||
|
||||
Responds to this interaction by sending a modal.
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
modal: :class:`~discord.ui.Modal`
|
||||
The modal to send.
|
||||
|
||||
Raises
|
||||
-------
|
||||
HTTPException
|
||||
Sending the modal failed.
|
||||
InteractionResponded
|
||||
This interaction has already been responded to before.
|
||||
"""
|
||||
if self._responded:
|
||||
raise InteractionResponded(self._parent)
|
||||
|
||||
parent = self._parent
|
||||
|
||||
adapter = async_context.get()
|
||||
|
||||
params = interaction_response_params(InteractionResponseType.modal.value, modal.to_dict())
|
||||
await adapter.create_interaction_response(
|
||||
parent.id,
|
||||
parent.token,
|
||||
session=parent._session,
|
||||
params=params,
|
||||
)
|
||||
|
||||
self._parent._state.store_view(modal)
|
||||
self._responded = True
|
||||
|
||||
|
||||
class _InteractionMessageState:
|
||||
__slots__ = ('_parent', '_interaction')
|
||||
|
||||
Reference in New Issue
Block a user