简体   繁体   English

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

[英]How can i delete role permissinos with discord.py

I accidentally did this我不小心做了这个在此处输入图像描述 in every channel with my bot.在我的机器人的每个频道中。 How can i remove them using a loop?如何使用循环删除它们?

You can use TextChannel.set_permissions to modify the permissions for a certain channel, in your case just iterate over the channels that you need.您可以使用TextChannel.set_permissions修改某个频道的权限,在您的情况下,只需遍历您需要的频道。

To be able to delete the permissions you will need to set the overwrite parameter to None :为了能够删除权限,您需要将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)

References:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM