Discord py - 覆盖不影响频道的权限

时间:2021-05-14 17:45:44

标签: python discord.py

我一直在尝试创建一个具有特定权限的频道。 一切似乎都很好,但是当我转到新创建的频道的设置时,它似乎没有任何效果。权限同步和覆盖都不影响通道。这是为什么 ? 我的代码:

role = discord.utils.get(ctx.guild.roles, name=arg.title())
            if role is None:
                role = await ctx.guild.create_role(name=arg.title())
            channel = discord.utils.get(ctx.guild.voice_channels, name=arg.title())
            if channel:
                if channel not in category.voice_channels:
                    await channel.move(category=category, beginning=True)
                await channel.set_permissions(role, connect=True, view_channel=True)
                await channel.set_permissions(ctx.guild.default_role, connect=False, view_channel=False)
            else:
                overwrites = {
                    ctx.guild.default_role: discord.PermissionOverwrite(connect=False, view_channel=False),
                    role: discord.PermissionOverwrite(connect=True, view_channel=True)
                }
                channel = await category.create_voice_channel(arg.title(), overwrite=overwrites)
            await channel.edit(sync_permissions=False)

附注: 我想将权限同步设置为 False 并且我只在创建频道后找到了一种方法。 创建时有没有办法做到这一点?

1 个答案:

答案 0 :(得分:0)

错误是由错误的关键字引起的

channel = await category.create_voice_channel(arg.title(), overwrite=overwrites)

overwrite 不是 category.create_voice_channel

的关键字参数

正确的用法是:

channel = await category.create_voice_channel(arg.title(), overwrites=overwrites)

参考文献:-