def format_usage(cmd: Command, server: discord.Server):
""" Format the usage string of the given command. Places any usage
of a sub command on a newline.
:param cmd: Type Command.
:param server: The server to generate the usage in.
:return: str: formatted usage.
"""
if cmd.hidden and cmd.parent is not None:
return
command_prefix = config.server_command_prefix(server)
usage = [cmd.usage(server)]
for sub_command in cmd.sub_commands:
# Recursively format the usage of the next sub commands
formatted = format_usage(sub_command, server)
if formatted:
usage.append(formatted)
return "\n".join(s for s in usage if s is not None).format(pre=command_prefix) if usage else None
评论列表
文章目录