1
0
Fork 0
mirror of synced 2024-06-26 10:10:44 +12:00

Made get_all_commands available

This commit is contained in:
Phxntxm 2017-02-12 15:55:49 -06:00
parent 31ed6b32fb
commit e90bab4a84
2 changed files with 4 additions and 4 deletions

View file

@ -90,7 +90,7 @@ class Core:
example = None
result = None
# Also get the subcommands for this command, if they exist
subcommands = [x for x in utils.get_all_commands(cmd) if x != cmd.qualified_name]
subcommands = [x for x in utils.get_subcommands(cmd) if x != cmd.qualified_name]
# The rest is simple, create the embed, set the thumbail to me, add all fields if they exist
embed = discord.Embed(title=cmd.qualified_name)

View file

@ -14,17 +14,17 @@ def get_all_commands(bot):
# Only the command itself will be yielded if there are no children
for cmd_name in parent_command_names:
cmd = bot.commands.get(cmd_name)
for child_cmd in _get_all_commands(cmd):
for child_cmd in get_subcommands(cmd):
all_commands.append(child_cmd)
return all_commands
def get_all_commands(command):
def get_subcommands(command):
yield command.qualified_name
try:
non_aliases = set(cmd.name for cmd in command.commands.values())
for cmd_name in non_aliases:
yield from _get_all_commands(command.commands[cmd_name])
yield from get_subcommands(command.commands[cmd_name])
except AttributeError:
pass