【问题标题】:Discord.py unmute error: 'coroutine' object is not callableDiscord.py 取消静音错误:“协程”对象不可调用
【发布时间】:2021-11-30 08:30:28
【问题描述】:

我一直在为我的 discord.py 机器人编写取消静音功能。完成后,我尝试运行它,并弹出此错误: “协程”对象不可调用

这是我的代码:

@bot.command(description="Unmutes a specified user.")
@commands(manage_messages=True)
async def unmute(ctx, member: discord.Member):
   mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")

   await member.remove_roles(mutedRole)
   await member.send(f" you have unmutedd from: - {ctx.guild.name}")
   embed = discord.Embed(title="unmute", description=f" unmuted-{member.mention}",colour=discord.Colour.green())
   await ctx.send(embed=embed)

我该怎么办?

【问题讨论】:

  • 请包含整个错误消息。哪条生产线生产它?
  • 不能把Python放到代码sn -p ????它仅适用于 html/css/javascript
  • 好吧,我可以,所以

标签: python discord discord.py bots


【解决方案1】:

装饰器@commands(manage_messages=True)不存在。

我假设您的意思是@commands.has_permissions(manage_messages=True)。应该可以的

https://discordpy.readthedocs.io/en/master/ext/commands/api.html?highlight=has%20permissions#discord.ext.commands.has_permissions

【讨论】:

  • 它仍然说:“命令”对象没有属性“has_permissions”。
  • 我的导入是:from discord.ext.commands import has_permissions, MissingPermissions
  • 导入from discord.ext import commands就够了
  • 修复了!我使用“命令”作为另一个命令的名称,这显然弄乱了我的其他代码。
猜你喜欢
  • 1970-01-01
  • 2019-12-06
  • 1970-01-01
  • 1970-01-01
  • 2021-01-12
  • 2013-09-15
  • 2019-03-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多