为我的 Discord.py 机器人制作自动帮助命令

时间:2021-01-22 23:44:06

标签: python discord discord.py discord.py-rewrite

我如何自动从

获取用法和描述
@bot.command(usage='ping', desc='gets bots latency')

我尝试了 get_command() commands all_commands 但他们没有返回任何东西。我使用 cog help 命令进行了另一次尝试,但仍然无法正常工作。有人可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

不要使用 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)

答案 1 :(得分:0)

嘿,亲爱的,这真的很容易..你只需要写这个:-

<块引用>

@bot.command(usage='ping', desc='gets bots delay', help='Gets bot's delay.')