获取缺少的权限

时间:2020-05-04 21:15:52

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

我如何获得缺少的许可? (api的“ missing_perms”)

elif isinstance(error, commands.MissingPermissions):
            await ctx.message.delete()
            error = discord.Embed(
                title = 'Error',
                description = 'Missing permission!',
                colour = discord.Colour.red()
            )
            error.set_footer(text=version)
            textMsg = await ctx.send(embed=error)
            await textMsg.delete(delay=4)

类似“ manage_guild”的

1 个答案:

答案 0 :(得分:1)

MissingPermissions对象具有属性missing_perms,该属性是缺少的权限的列表:

elif isinstance(error, commands.MissingPermissions):
            await ctx.message.delete()
            embed= discord.Embed(
                title = 'Error',
                description = f'Missing permissions: {error.missing_perms}',
                colour = discord.Colour.red()
            )
            embed.set_footer(text=version)
            textMsg = await ctx.send(embed=embed)
            await textMsg.delete(delay=4)