Update to match the new commands format
This commit is contained in:
parent
0806cdadb2
commit
3edd9b64de
|
@ -45,7 +45,7 @@ class Core:
|
|||
cmd = self.bot.get_command(message)
|
||||
|
||||
if cmd is None:
|
||||
entries = sorted(utils.get_all_commands(self.bot))
|
||||
entries = sorted([cmd.qualified_name for cmd in utils.get_all_commands(self.bot)])
|
||||
try:
|
||||
pages = utils.Pages(self.bot, message=ctx.message, entries=entries)
|
||||
await pages.paginate(start_page=page)
|
||||
|
|
|
@ -22,27 +22,16 @@ def convert_to_jpeg(pfile):
|
|||
def get_all_commands(bot):
|
||||
"""Returns a list of all command names for the bot"""
|
||||
# First lets create a set of all the parent names
|
||||
parent_command_names = set(cmd.qualified_name for cmd in bot.commands.values())
|
||||
all_commands = []
|
||||
|
||||
# Now lets loop through and get all the child commands for each command
|
||||
# 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_subcommands(cmd):
|
||||
all_commands.append(child_cmd)
|
||||
|
||||
return all_commands
|
||||
for cmd in bot.commands:
|
||||
yield from _get_all_subcommands(cmd)
|
||||
|
||||
|
||||
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_subcommands(command.commands[cmd_name])
|
||||
except AttributeError:
|
||||
pass
|
||||
def _get_all_subcommands(command):
|
||||
yield command
|
||||
if type(command) is discord.ext.commands.core.Group:
|
||||
for subcmd in command.commands:
|
||||
yield from _get_all_subcommands(subcmd)
|
||||
|
||||
|
||||
async def channel_is_nsfw(channel):
|
||||
if channel is discord.DMChannel:
|
||||
|
|
Loading…
Reference in a new issue