diff --git a/interactions/client/client.py b/interactions/client/client.py index fe9a5ff6f..3c4fed523 100644 --- a/interactions/client/client.py +++ b/interactions/client/client.py @@ -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 @@ -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: diff --git a/interactions/ext/hybrid_commands/manager.py b/interactions/ext/hybrid_commands/manager.py index 6de809e67..9cf5f464d 100644 --- a/interactions/ext/hybrid_commands/manager.py +++ b/interactions/ext/hybrid_commands/manager.py @@ -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: @@ -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, ) @@ -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, )