Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions interactions/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,17 @@ def add_modal_callback(self, command: ModalCommand) -> None:
Args:
command: The command to add
"""
# test for parameters that arent the ctx (or self)
if command.has_binding:
callback = functools.partial(command.callback, None, None)
else:
callback = functools.partial(command.callback, None)

if not inspect.signature(callback).parameters:
# if there are none, notify the command to just pass the ctx and not kwargs
# TODO: just make modal callbacks not pass kwargs at all (breaking)
command._just_ctx = True

for listener in command.listeners:
if isinstance(listener, re.Pattern):
if listener in self._regex_component_callbacks.keys():
Expand Down
7 changes: 6 additions & 1 deletion interactions/models/internal/application_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,12 @@ class ComponentCommand(InteractionCommand):

@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class ModalCommand(ComponentCommand):
...
_just_ctx: bool = attrs.field(repr=False, default=False)

async def call_callback(self, callback: Callable, context: "BaseContext") -> None:
if self._just_ctx:
return await self.call_with_binding(callback, context)
return await super().call_callback(callback, context)


def _unpack_helper(iterable: typing.Iterable[str]) -> list[str]:
Expand Down