discord.py - 如果角色获得了用户没有的权限,则修改不能使用的角色的命令
discord.py - Command to modify roles that cannot be used if role has got permissions the user don't have
我正在使用 discord.py-rewrite
库制作 Discord BOT,但我遇到了问题。
事实上,我正在制作一个命令,可以从我们指定的角色中删除所有权限。但是我希望这个命令只能被具有Manage Roles
权限的成员使用,但是成员还必须拥有他们正在修改的角色的所有权限。
例如,成员 具有 Manage Roles
权限但 没有 View Audit Log
权限 WON'T能够 以 View Audit Log
权限在角色 上执行此命令。
现在有人问我该如何处理吗?
获取角色和作者的Permissions
,然后确认角色权限是作者权限的子集:
@bot.command()
@has_permissions(manage_roles=True)
async def remove_role(ctx, *, role: Role):
if role.permissions <= ctx.author.permissions_in(ctx.message.channel):
...
else:
await ctx.send("You are missing permissions")
我正在使用 discord.py-rewrite
库制作 Discord BOT,但我遇到了问题。
事实上,我正在制作一个命令,可以从我们指定的角色中删除所有权限。但是我希望这个命令只能被具有Manage Roles
权限的成员使用,但是成员还必须拥有他们正在修改的角色的所有权限。
例如,成员 具有 Manage Roles
权限但 没有 View Audit Log
权限 WON'T能够 以 View Audit Log
权限在角色 上执行此命令。
现在有人问我该如何处理吗?
获取角色和作者的Permissions
,然后确认角色权限是作者权限的子集:
@bot.command()
@has_permissions(manage_roles=True)
async def remove_role(ctx, *, role: Role):
if role.permissions <= ctx.author.permissions_in(ctx.message.channel):
...
else:
await ctx.send("You are missing permissions")