diff options
| author | Rapptz <[email protected]> | 2019-02-23 10:51:23 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-02-23 10:51:23 -0500 |
| commit | ab8e7b77320b6bdcc67b0b0f6ee5144e07bb2f09 (patch) | |
| tree | 246e185d63e71d244aa38b2f502eb8c19e1a8199 | |
| parent | Better jpeg detection in utils._get_mime_type_for_image (diff) | |
| download | discord.py-ab8e7b77320b6bdcc67b0b0f6ee5144e07bb2f09.tar.xz discord.py-ab8e7b77320b6bdcc67b0b0f6ee5144e07bb2f09.zip | |
[commands] Fix bug in behaviour in the cog inspection methods.
| -rw-r--r-- | discord/ext/commands/cog.py | 15 | ||||
| -rw-r--r-- | docs/ext/commands/cogs.rst | 2 |
2 files changed, 11 insertions, 6 deletions
diff --git a/discord/ext/commands/cog.py b/discord/ext/commands/cog.py index 6096fa68..3f07dd6b 100644 --- a/discord/ext/commands/cog.py +++ b/discord/ext/commands/cog.py @@ -156,18 +156,23 @@ class Cog(metaclass=CogMeta): return self def get_commands(self): - r"""Returns a :class:`tuple` of :class:`.Command`\s and its subclasses that are + r"""Returns a :class:`list` of :class:`.Command`\s that are defined inside this cog. + + .. note:: + + This does not include subcommands. """ - return self.__cog_commands__ + return [c for c in self.__cog_commands__ if c.parent is None] def walk_commands(self): """An iterator that recursively walks through this cog's commands and subcommands.""" from .core import GroupMixin for command in self.__cog_commands__: - yield command - if isinstance(command, GroupMixin): - yield from command.walk_commands() + if command.parent is None: + yield command + if isinstance(command, GroupMixin): + yield from command.walk_commands() def get_listeners(self): """Returns a :class:`list` of (name, function) listener pairs that are defined in this cog.""" diff --git a/docs/ext/commands/cogs.rst b/docs/ext/commands/cogs.rst index 680a5246..589a94c2 100644 --- a/docs/ext/commands/cogs.rst +++ b/docs/ext/commands/cogs.rst @@ -142,7 +142,7 @@ Inspection Since cogs ultimately are classes, we have some tools to help us inspect certain properties of the cog. -To get a :class:`tuple` of commands, we can use :meth:`.Cog.get_commands`. :: +To get a :class:`list` of commands, we can use :meth:`.Cog.get_commands`. :: >>> cog = bot.get_cog('Greetings') >>> commands = cog.get_commands() |