From d5d49871e1bb37896cfb5588a74d150268b505cd Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Thu, 9 May 2024 10:49:09 +0300 Subject: [PATCH] Keep original value of the cog attribute (#7) * Keep original value of the cog attribute * Format --- pycord/multicog/__init__.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/pycord/multicog/__init__.py b/pycord/multicog/__init__.py index 172adb6..131bbe5 100644 --- a/pycord/multicog/__init__.py +++ b/pycord/multicog/__init__.py @@ -60,11 +60,8 @@ 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, - group, - group.guild_ids, - ) + command.parent = group + command.guild_ids = group.guild_ids group.add_command(command) multicog_commands[index] = command @@ -91,7 +88,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 +104,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 +133,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):