discord.py如何组织帮助命令



我得到了所有的命令工作,但我不知道我怎么能排序他们像:

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

我最终通过使用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)

最新更新