Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions interactions/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ def decorator(coro: Coroutine) -> Any:

return decorator

def modal(self, modal: Modal) -> Callable[..., Any]:
def modal(self, modal: Union[Modal, str]) -> Callable[..., Any]:
"""
A decorator for listening to ``INTERACTION_CREATE`` dispatched gateway
events involving modals.
Expand Down Expand Up @@ -654,14 +654,15 @@ async def modal_response(ctx):
The context of the modal callback decorator inherits the same
as of the component decorator.

:param modal: The modal you wish to callback for.
:type modal: Modal
:param modal: The modal or custom_id of modal you wish to callback for.
:type modal: Union[Modal, str]
:return: A callable response.
:rtype: Callable[..., Any]
"""

def decorator(coro: Coroutine) -> Any:
return self.event(coro, name=f"modal_{modal.custom_id}")
payload: str = modal.custom_id if isinstance(modal, Modal) else modal
return self.event(coro, name=f"modal_{payload}")

return decorator

Expand Down
2 changes: 1 addition & 1 deletion interactions/client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Client:
) -> Callable[..., Any]: ...
def component(self, component: Union[Button, SelectMenu]) -> Callable[..., Any]: ...
def autocomplete(self, name: str, command: Union[ApplicationCommand, int, str]) -> Callable[..., Any]: ...
def modal(self, modal: Modal) -> Callable[..., Any]: ...
def modal(self, modal: Union[Modal, str]) -> Callable[..., Any]: ...
def load(
self, name: str, package: Optional[str] = None, *args, **kwargs
) -> Optional["Extension"]: ...
Expand Down