Skip to content

Commit

Permalink
fix: subcommands having MISSING cog attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Middledot authored and Lulalaby committed Aug 26, 2022
1 parent 32ac873 commit a2b1d8f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,10 +968,6 @@ def _update_copy(self, kwargs: Dict[str, Any]):
else:
return self.copy()

def _set_cog(self, cog):
super()._set_cog(cog)
self._validate_parameters()


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

return as_dict

def add_command(self, command: SlashCommand) -> None:
if command.cog is MISSING:
command.cog = self.cog

self.subcommands.append(command)

def command(self, cls: Type[T] = SlashCommand, **kwargs) -> Callable[[Callable], SlashCommand]:
def wrap(func) -> T:
command = cls(func, parent=self, **kwargs)
self.subcommands.append(command)
self.add_command(command)
return command

return wrap
Expand Down

0 comments on commit a2b1d8f

Please sign in to comment.