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
6 changes: 3 additions & 3 deletions interactions/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,9 @@ def add_command(self, func: Callable) -> None:
elif not isinstance(func, BaseCommand):
raise TypeError("Invalid command type")

for hook in self._add_command_hook:
hook(func)

if not func.callback:
# for group = SlashCommand(...) usage
return
Expand All @@ -1499,9 +1502,6 @@ def add_command(self, func: Callable) -> None:
else:
self.logger.debug(f"Added callback: {func.callback.__name__}")

for hook in self._add_command_hook:
hook(func)

self.dispatch(CallbackAdded(callback=func, extension=func.extension if hasattr(func, "extension") else None))

def _gather_callbacks(self) -> None:
Expand Down
25 changes: 23 additions & 2 deletions interactions/ext/hybrid_commands/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,27 @@ def _add_hybrid_command(self, callback: Callable):
return

cmd = callback

if not cmd.callback or cmd._dummy_base:
if cmd.group_name:
if not (group := self.client.prefixed.get_command(f"{cmd.name} {cmd.group_name}")):
group = base_subcommand_generator(
str(cmd.group_name),
list(_values_wrapper(cmd.group_name.to_locale_dict())) + cmd.aliases,
str(cmd.group_name),
group=True,
)
self.client.prefixed.commands[str(cmd.name)].add_command(group)
elif not (base := self.client.prefixed.commands.get(str(cmd.name))):
base = base_subcommand_generator(
str(cmd.name),
list(_values_wrapper(cmd.name.to_locale_dict())) + cmd.aliases,
str(cmd.name),
group=False,
)
self.client.prefixed.add_command(base)
return

prefixed_transform = slash_to_prefixed(cmd)

if self.use_slash_command_msg:
Expand All @@ -91,7 +112,7 @@ def _add_hybrid_command(self, callback: Callable):
if not (base := self.client.prefixed.commands.get(str(cmd.name))):
base = base_subcommand_generator(
str(cmd.name),
list(_values_wrapper(cmd.name.to_locale_dict())) + cmd.aliases,
list(_values_wrapper(cmd.name.to_locale_dict())),
str(cmd.name),
group=False,
)
Expand All @@ -102,7 +123,7 @@ def _add_hybrid_command(self, callback: Callable):
if not (group := base.subcommands.get(str(cmd.group_name))):
group = base_subcommand_generator(
str(cmd.group_name),
list(_values_wrapper(cmd.group_name.to_locale_dict())) + cmd.aliases,
list(_values_wrapper(cmd.group_name.to_locale_dict())),
str(cmd.group_name),
group=True,
)
Expand Down