如何在discord.py中为命令参数添加描述?

Gla*_*ung 2 python bots discord discord.py

假设我有这个命令:

@bot.command(description='command do some stuff')
async def somecommand(ctx: commands.Context, arg1:str, arg2:str = "hello"):
    await ctx.channel.send(arg1+arg2)
Run Code Online (Sandbox Code Playgroud)

当我调用 help command:!help somecommand或 ?help somecommand (取决于前缀)时
,它返回:

在此输入图像描述

如何为参数添加描述?

sti*_*dcl 6

用作commands.parameter()值,并设置descriptionkwarg。唯一的区别是,要给它一个默认值,您现在必须使用defaultkwarg ofcommands.parameter()而不是直接将其传递到函数中。

async def some_command(ctx, arg1: str = commands.parameter(default="Here be default", description="Here be description"))
Run Code Online (Sandbox Code Playgroud)

带有示例的文档:https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.parameter