Skip to content

Commit 375583f

Browse files
MiddledotBobDotCom
authored andcommitted
fix: subcommands having MISSING cog attribute
1 parent 2a4595e commit 375583f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

discord/commands/core.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -968,10 +968,6 @@ def _update_copy(self, kwargs: Dict[str, Any]):
968968
else:
969969
return self.copy()
970970

971-
def _set_cog(self, cog):
972-
super()._set_cog(cog)
973-
self._validate_parameters()
974-
975971

976972
class SlashCommandGroup(ApplicationCommand):
977973
r"""A class that implements the protocol for a slash command group.
@@ -1090,10 +1086,16 @@ def to_dict(self) -> Dict:
10901086

10911087
return as_dict
10921088

1089+
def add_command(self, command: SlashCommand) -> None:
1090+
if command.cog is MISSING:
1091+
command.cog = self.cog
1092+
1093+
self.subcommands.append(command)
1094+
10931095
def command(self, cls: Type[T] = SlashCommand, **kwargs) -> Callable[[Callable], SlashCommand]:
10941096
def wrap(func) -> T:
10951097
command = cls(func, parent=self, **kwargs)
1096-
self.subcommands.append(command)
1098+
self.add_command(command)
10971099
return command
10981100

10991101
return wrap

0 commit comments

Comments
 (0)