【问题标题】:Making an automatic help command for my Discord.py bot为我的 Discord.py 机器人创建自动帮助命令
【发布时间】:2021-01-27 16:20:58
【问题描述】:
我如何自动从
获取用法和描述
@bot.command(usage='ping', desc='gets bots latency')
我试过get_command() commands all_commands 但他们没有返回任何东西。我再次尝试使用 cog help 命令,但仍然无法工作。有人可以帮忙吗?
【问题讨论】:
标签:
python
discord
discord.py
discord.py-rewrite
【解决方案1】:
不要使用 Discord 的默认帮助命令,而是使用 client.remove_command('help')。这只是从您的机器人中删除了默认命令“帮助”。这样,您现在可以替换并制作自己的,但您必须手动添加它们。
我还建议使用嵌入,因为这也有助于使命令看起来更清晰并组织每个命令的显示。
@client.command()
async def help(ctx):
embed = discord.Embed(colour=0x7289DA, timestamp=ctx.message.created_at)
embed.add_field(name='Help commands', value='Please refer to the commands listed below for commands available for use', inline=True)
embed.add_field(name='command name', value='details about this command', inline=True)
embed.set_footer(text=f"Help commands")
await ctx.send(embed=embed)
【解决方案2】:
嘿,亲爱的,这真的很简单。你只需要写这个:-
@bot.command(usage='ping', desc='获取机器人延迟', help='获取机器人延迟。')