如何使用 discord.py 删除角色权限

时间:2021-02-12 06:46:45

标签: python discord discord.py

我不小心在每个频道中用我的机器人做了这个enter image description here。如何使用循环删除它们?

1 个答案:

答案 0 :(得分:1)

您可以使用 TextChannel.set_permissions 修改特定频道的权限,在您的情况下,只需遍历您需要的频道。

要删除权限,您需要将 overwrite 参数设置为 None

@client.command()
async def delete_perms(ctx):
    channel_list = [ ]  # Here goes the list of channel IDs to modify
    member_list = [ ] # Here goes the list of member IDs that you want to remove permissions
    for channel in channel_list:
        channel_i = ctx.guild.get_channel(channel)
        for member in member_list:
            member_i = ctx.guild.get_member(member)
            await channel_i.set_permissions(member_i, overwrite=None)

参考文献: