Skip to content

Commit

Permalink
Keep original value of the cog attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorukyum committed Apr 26, 2024
1 parent 076567c commit 0de68ff
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions pycord/multicog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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):
Expand Down

0 comments on commit 0de68ff

Please sign in to comment.