【问题标题】:Why doesn't my discord bot help command work?为什么我的不和谐机器人帮助命令不起作用?
【发布时间】: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


【解决方案1】:

Silvio Mayolo 在 cmets 中:

解决方案是:@client.command 替换为@client.group

【讨论】:

    【解决方案2】:

    @help 更改为@client 上方的async def kick

    【讨论】:

      猜你喜欢
      • 2021-02-25
      • 2021-10-05
      • 2023-03-20
      • 2020-11-22
      • 2018-11-10
      • 2018-11-29
      • 1970-01-01
      • 2020-09-25
      • 2018-07-21
      相关资源
      最近更新 更多