首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何编辑不一致机器人命令的描述,如默认帮助命令中所示?

问如何编辑不一致机器人命令的描述,如默认帮助命令中所示?
EN

Stack Overflow用户
提问于 2017-12-18 06:04:44
回答 1查看 10.9K关注 0票数 5

我正在用Python开发一个不和谐的机器人。当用户对特定命令调用help命令时,机器人会返回指定的命令--但不会对该命令进行任何描述(除了默认的帮助命令本身)。

例如:

代码语言:javascript
复制
User: e!help question
Bot: e!question [question...]

但是已经定义了help命令的描述:

代码语言:javascript
复制
User: e!help help
Bot: e!help [commands...] | Shows this message.

如何编辑命令的描述?

EN

回答 1

Stack Overflow用户

发布于 2017-12-18 22:34:57

可以在创建命令时使用brief和description将详细信息添加到help命令。请参阅下面的示例代码。

代码语言:javascript
复制
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将显示以下内容

代码语言:javascript
复制
​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将显示以下内容

代码语言:javascript
复制
This is the full description

!foo
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47859913

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档