烫发错误后,Discord机器人不会响应

时间:2020-08-28 11:01:42

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

所以我正在制造这个机器人,并且该命令需要特定的权限才能操作。

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}")

在打印行之后,它显示一条错误消息,指出“ MissingPermissions”没有名为“ message”的属性

1 个答案:

答案 0 :(得分:0)

将此行await ctx.send_message(ctx.message.channel, text)更改为-

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