【问题标题】:Discord bot won't respond after a perms error出现烫发错误后,Discord bot 不会响应
【发布时间】:2020-12-17 07:30:55
【问题描述】:

所以我正在制作这个机器人,这个特定的命令需要特定的权限才能运行。

from discord import Member
from discord.ext.commands import has_permissions, MissingPermissions

@bot.command(aliases=["purge"], pass_context=True)
@has_permissions(manage_channels=True, manage_messages=True)
async def clear(ctx, amount=20):
  await ctx.channel.purge(limit=amount)
  await ctx.send(f"{amount} messages, reduced to atoms")

@clear.error
async def clear_error(error,ctx):
  if isinstance(error, MissingPermissions):
        text = ("It seems you don't have the permissions for this, ".format(ctx.message.author))
        await ctx.send_message(ctx.message.channel, text)

由于某种原因,声明没有得到满足,也没有给出回应。所以我添加了一个 else(即使不应该有)

else:
    print("authorised user tried to access but hit an error")
    await ctx.send_message(f"there seems to be an error,{ctx.message.author}")

在打印行之后,它遇到一条错误消息,说没有名为“message”的属性到“MissingPermissions”

【问题讨论】:

    标签: python python-3.x discord discord.py


    【解决方案1】:

    把这行await ctx.send_message(ctx.message.channel, text)改成-

    await ctx.send(f"there seems to be an error,{ctx.message.author}")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-17
      • 2020-12-15
      • 2021-08-28
      • 2019-08-26
      • 2021-02-17
      • 2023-03-09
      相关资源
      最近更新 更多