From 0de68ffefde7f754629de016b2f13048892717ab Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Fri, 26 Apr 2024 22:06:43 +0300 Subject: [PATCH] Keep original value of the cog attribute --- pycord/multicog/__init__.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pycord/multicog/__init__.py b/pycord/multicog/__init__.py index 172adb6..224a165 100644 --- a/pycord/multicog/__init__.py +++ b/pycord/multicog/__init__.py @@ -60,8 +60,7 @@ def _add_to_group( """A helper funcion to change attributes of a command to match those of the target group's.""" index = multicog_commands.index(command) - command.cog, command.parent, command.guild_ids = ( - group.cog, + command.parent, command.guild_ids = ( group, group.guild_ids, ) @@ -91,7 +90,6 @@ def add_application_command(self, command: discord.ApplicationCommand) -> None: ): for subcommand in group.subcommands: command.subcommands.append(subcommand) - subcommand.cog = group.cog super().remove_application_command(group) @@ -108,12 +106,10 @@ def add_application_command(self, command: discord.ApplicationCommand) -> None: options = meta.group_options or {} if " " not in meta.group: group = discord.SlashCommandGroup(meta.group, **options) - group.cog = command.cog self._add_to_group(command, group) else: group_name, subgroup_name = meta.group.split(" ") group = discord.SlashCommandGroup(group_name, **options) - group.cog = command.cog subgroup = group.create_subgroup(subgroup_name) self._add_to_group(command, subgroup) @@ -139,11 +135,8 @@ def remove_application_command( ): command.subcommands.remove(subcommand) - if command.subcommands: - command.cog = command.subcommands[0].cog - return - - return super().remove_application_command(command) + if not command.subcommands: + return super().remove_application_command(command) class AutoShardedBot(discord.AutoShardedBot, Bot):