help.py 文件源码

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

项目:HAHA-NO-UR 作者: DamourYouKnow 项目源码 文件源码
def get_help(bot) -> tuple:
    """
    Return a general Embed onject for help.
    :param bot: the Yasen instance.
    :return: a discord Embed object for general help.
    """
    from bot import __title__ as name
    prefix = bot.prefix
    description = f'For detailed help please use {prefix}help [command_name]'
    embed = Embed(colour=bot.colour, description=description)
    embed.set_author(name=f'{name} Help', icon_url=bot.user.avatar_url)
    cog_cmd = {}
    all_help = {}
    for command in bot.commands.values():
        _name = command.name
        for n in __resolve_alias(command):
            all_help[n] = single_help(bot, command, _name)
        cog_name = ' '.join(split_camel(command.cog_name) + ['Commands'])
        if cog_name not in cog_cmd:
            cog_cmd[cog_name] = []
        cog_cmd[cog_name].append(f'`{_name}`')
        if isinstance(command, Group):
            for sub in command.commands.values():
                _child_name = sub.name
                full_name = f'{_name} {_child_name}'
                all_help[full_name] = single_help(bot, sub, full_name)
                cog_cmd[cog_name].append(full_name)
    for key in sorted(cog_cmd.keys()):
        embed.add_field(
            name=key, value=', '.join(set(cog_cmd[key])), inline=False
        )
    return embed, all_help
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号