【发布时间】: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