我正在使用 discord.py 工作一个不和谐的机器人。我正在处理错误,我发现了这个
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
这是我的错误处理代码:-
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send("You can't do that ;-;")
await ctx.message.delete()
elif isinstance(error, commands.MissingRequiredArgument):
await ctx.send("Please enter all the required arguements")
await ctx.message.delete()
elif isinstance(error, commands.MemberNotFound):
await ctx.send("Member not found, Please mention a valid user!")
await ctx.message.delete()
elif isinstance(error, commands.BotMissingPermissions):
await ctx.send("I don't have the permissions to do that!")
await ctx.message.delete()
elif isinstance(error, Forbidden.MissingPermissions):
await ctx.send("I don't have the permissions to do that!")
await ctx.message.delete()
else:
raise error
我还有一个静音命令,当机器人被放置在被命令静音的角色下时,它会说,“我不能这样做。将我的角色放在指定的角色之上”或类似的东西