python-3.x之如何编辑 Discord 机器人命令的描述,如默认帮助命令中所示

over140 阅读:21 2024-12-31 21:38:35 评论:0

我正在用 Python 开发一个 Discord 机器人。当用户调用help在特定命令上执行命令时,机器人会发回指定的命令——但没有对该命令的描述(默认帮助命令本身除外)。

例如:

User: e!help question 
Bot: e!question [question...] 

但是 help 的描述命令已经定义:
User: e!help help 
Bot: e!help [commands...] | Shows this message. 

我将如何编辑命令的描述?

请您参考如下方法:

您可以使用 briefdescription创建命令以向帮助命令添加详细信息时。请参阅下面的示例代码。

from discord.ext import commands 
 
bot_prefix = '!' 
 
client = commands.Bot(command_prefix=bot_prefix) 
 
@client.command(brief='This is the brief description', description='This is the full description') 
async def foo(): 
    await client.say('bar') 
 
client.run('TOKEN') 

使用 !help将显示以下内容
​No Category: 
  help Shows this message. 
  foo  This is the brief description 
 
Type !help command for more info on a command. 
You can also type !help category for more info on a category. 

使用 !help foo将显示以下内容
This is the full description 
 
!foo 


标签:Python
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号