__init__.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:pcbot 作者: pckv 项目源码 文件源码
def format_help(cmd: Command, server: discord.Server, no_subcommand: bool=False):
    """ Format the help string of the given command as a message to be sent.

    :param cmd: Type Command
    :param server: The server to generate help in.
    :param no_subcommand: Use only the given command's usage.
    :return: str: help message.
    """
    usage = cmd.usage(server) if no_subcommand else format_usage(cmd, server)

    # If there is no usage, the command isn't supposed to be displayed as such
    # Therefore, we switch to using the parent command instead
    if usage is None and cmd.parent is not None:
        return format_help(cmd.parent, server)

    command_prefix = config.server_command_prefix(server)
    desc = cmd.description.format(pre=command_prefix)

    # Format aliases
    alias_format = ""
    if cmd.aliases:
        # Don't add blank space unless necessary
        if not desc.strip().endswith("```"):
            alias_format += "\n"

        alias_format += "**Aliases**: ```{}```".format(
            ", ".join((command_prefix if identifier_prefix.match(alias[0]) and cmd.parent is None else "") +
                      alias for alias in cmd.aliases))

    return "**Usage**: ```{}```**Description**: {}{}".format(usage, desc, alias_format)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号