Skip to content

Commit 511f273

Browse files
committed
use built-in group.walk_commands()
1 parent dbaf8ff commit 511f273

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

discord/cog.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,7 @@ def walk_commands(self) -> Generator[ApplicationCommand, None, None]:
276276
"""
277277
for command in self.__cog_commands__:
278278
if isinstance(command, SlashCommandGroup):
279-
for subcommand in command.subcommands:
280-
if subcommand.parent is not None:
281-
for sub_subcommand in subcommand.subcommands:
282-
yield sub_subcommand
283-
else:
284-
yield subcommand
279+
yield from command.walk_commands()
285280

286281
def get_listeners(self) -> List[Tuple[str, Callable[..., Any]]]:
287282
"""Returns a :class:`list` of (name, function) listener pairs that are defined in this cog.

discord/ext/commands/cog.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,14 @@ def walk_commands(self) -> Generator[Command, None, None]:
5959
A command or group from the cog.
6060
"""
6161
from .core import GroupMixin
62-
print(self.__cog_commands__)
6362
for command in self.__cog_commands__:
6463
if not isinstance(command, ApplicationCommand):
6564
if command.parent is None:
6665
yield command
6766
if isinstance(command, GroupMixin):
6867
yield from command.walk_commands()
6968
elif isinstance(command, SlashCommandGroup):
70-
for subcommand in command.subcommands:
71-
print(subcommand)
72-
print(subcommand.parent)
73-
if subcommand.parent is not None and isinstance(subcommand, SlashCommandGroup):
74-
print("reach")
75-
for sub_subcommand in subcommand.subcommands:
76-
yield sub_subcommand
77-
else:
78-
yield subcommand
69+
yield from command.walk_commands()
7970
else:
8071
yield command
8172

0 commit comments

Comments
 (0)