我的 discord bot 帮助命令不起作用。我希望它提供带有可用命令的嵌入式消息,因此我进行了以下操作:
@client.command(invoke_without_command = True)
async def help(ctx):
em = discord.Embed(title = "Help", description = "Use &help <command> for get info about a specific command")
em.add_field(name = "Moderation", value = "&kick, &ban, &unban, &mute, &unmute")
await ctx.send(embed = em)
@help.command()
async def kick(ctx):
em = discord.Embed(title = "Kick", description = "Kicks a member from the server", color = ctx.author.color)
em.add_field(name = "**Syntax**", value = "&kick <@member>")
await ctx.send(embed = em)
但是,在运行它时,它显示以下错误:
Traceback (most recent call last):
File "main.py", line 125, in <module>
@help.command()
AttributeError: 'Command' object has no attribute 'command'
我参考了很多 YouTube 视频,但是,所有视频都使用了相同的代码并且没有出现错误。你能帮我解决这个错误吗?
答案 0 :(得分:1)
评论中的Silvio Mayolo:
解决方案是:用@client.command
替换@client.group
答案 1 :(得分:0)
在您的 @help
上方将 @client
更改为 async def kick