def format(self):
"""
Formats the help page.
"""
# Adapted from discord.ext.commands.formatter.HelpFormatter.format
self._paginator = AryasPaginator()
description = self.command.description if not self.is_cog() else inspect.getdoc(self.command)
if description:
self._paginator.new_page(description=description)
if isinstance(self.command, Command):
# long help doc
if self.command.help:
self._paginator.add_line(self.command.help)
self._paginator.set_name(self.get_command_signature())
self._paginator.make_field(inline=False)
# if it's just a single command we're done here
if not self.has_subcommands():
return self._paginator.pages
# Helper method for sorting by category (cog)
def category(tup):
cog = tup[1].cog_name
# Unicode invisible space is there to set No Category last
return cog + ':' if cog is not None else '\u200bNo Category:'
# if command is a bot we need to process the entire command list
if self.is_bot():
data = sorted(self.filter_command_list(), key=category)
for category, commands in itertools.groupby(data, key=category):
commands = list(commands)
if len(commands) > 0:
self._add_entries(commands)
self._paginator.set_name(category)
self._paginator.make_field(inline=False)
else:
# if command is just a cog or Group we can print all the commands
# returned by filter_command_list
self._add_entries(self.filter_command_list())
self._paginator.set_name('Commands:')
self._paginator.make_field(inline=False)
# Get the ending message
self._paginator.set_name('More:')
self._paginator.add_line(self.get_ending_note())
self._paginator.make_field(inline=False)
return self._paginator.pages
评论列表
文章目录