出现烫发错误后,Discord bot 不会响应

Posted

技术标签:

【中文标题】出现烫发错误后,Discord bot 不会响应【英文标题】:Discord bot won't respond after a perms error 【发布时间】: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”

【问题讨论】:

【参考方案1】:

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

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

【讨论】:

以上是关于出现烫发错误后,Discord bot 不会响应的主要内容,如果未能解决你的问题,请参考以下文章