如何更改discord.py和Python所有文本频道的权限?
How to change the permission of all text channels with discord.py and Python?
我想做一个命令,允许修改discord.py所有文本频道的权限。例如,禁止在所有文本频道中发送消息。
我查看了 discord.py 的文档,我看到有一个 PermissionOverwrite class (https://discordpy.readthedocs.io/en/latest/api.html?highlight=app#permissionoverwrite) 允许在权限级别做一些事情(特别是随着功能更新)。
@client.command()
async def lock(ctx):
ctx.channel.set_permissions(ctx.guild.default_role, send_messages=False)
您可以简单地为每个频道使用 Guild.channels
for a list of all the channels in the server and GuildChannel.set_permissions
,就像您已经在使用的那样。
我想做一个命令,允许修改discord.py所有文本频道的权限。例如,禁止在所有文本频道中发送消息。
我查看了 discord.py 的文档,我看到有一个 PermissionOverwrite class (https://discordpy.readthedocs.io/en/latest/api.html?highlight=app#permissionoverwrite) 允许在权限级别做一些事情(特别是随着功能更新)。
@client.command()
async def lock(ctx):
ctx.channel.set_permissions(ctx.guild.default_role, send_messages=False)
您可以简单地为每个频道使用 Guild.channels
for a list of all the channels in the server and GuildChannel.set_permissions
,就像您已经在使用的那样。