【问题标题】:discord.py how to organize help commanddiscord.py 如何组织帮助命令
【发布时间】:2021-01-23 13:19:10
【问题描述】:

我让所有命令都能正常工作,但我不知道如何对它们进行排序:

Images:
avatar <user> > get someones avatar
etc.
Text:
clap <text> > generate text with clapping emojis
etc.

这是我现在拥有的:

@bot.command(usage="test [command]", description="get help")
async def test2(ctx, args=None):
dude = ''
if args is None:
    for i,x in enumerate(bot.commands):
        dude += (f'{PREFIX}{x.usage} » {x.description}\n')
    await ctx.send(f'```{dude}```')

我尝试将它们作为组,但后来意识到我必须将它们与图像头像@peter 一起使用

【问题讨论】:

    标签: python discord discord.py discord.py-rewrite


    【解决方案1】:

    我最终通过使用brief='x_command' 来识别命令类别来解决问题

    @bot.command(usage="test [command]", description="get help")
    async def test2(ctx, args=None):
    dude = ''
    if args is None:
        for i,x in enumerate(bot.commands):
            if x.brief == 'image_command':
                dude += (f'{PREFIX}{x.usage} » {x.description}\n')
        await ctx.send(f'```{dude}```')
    

    所以命令看起来像这样

    @bot.command(brief='image_command',usage="avatar <user>", description="send users avatar to chat")
    async def avatar(icy, user:discord.User):
    await icy.message.delete()
    await icy.send(user.avatar_url)
    

    【讨论】:

      猜你喜欢
      • 2020-11-06
      • 2021-09-16
      • 2021-04-21
      • 2021-12-10
      • 2021-06-13
      • 2021-01-01
      • 2019-03-17
      • 2020-10-19
      • 2019-07-16
      相关资源
      最近更新 更多