【发布时间】:2021-07-26 11:38:31
【问题描述】:
我的 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 视频,但是,它们都使用了相同的代码并且没有出错。你能帮我解决这个错误吗?
【问题讨论】:
-
您的意思是
@client.group而不是@client.command? -
您的建议有效,我会将您的答案标记为正确,但请将其作为答案发布,而不是评论。
-
很高兴我能帮上忙。 FlexGames 可以享有盛誉,因为他们似乎已经打败了我。干杯! :)
标签: python discord.py