简体   繁体   English

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

[英]Discord py - Overwrite permissions not affecting the channel

I have been trying to create a channel with specific permissions.我一直在尝试创建具有特定权限的频道。 Everything seems to work just fine, yet when I go to the settings of the newly created channel, it didn't seem to have any effects.一切似乎都很好,但是当我 go 到新创建的通道的设置时,它似乎没有任何效果。 Neither the permission syncing, nor the overwrites affected the channel.权限同步和覆盖都不会影响频道。 Why is that?这是为什么? My code:我的代码:

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)

PS: I want to set to False the permission syncing and I only found a way to do it after the channel was created. PS:我想将权限同步设置为 False,我只是在创建频道后才找到一种方法。 Is there a way to do it when creating?创建时有没有办法做到这一点?

The error is caused by the wrong keyword in该错误是由错误的关键字引起的

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

overwrite is not a keyword arg for category.create_voice_channel overwrite不是category.create_voice_channel的关键字 arg

The correct usage would be:正确的用法是:

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

References:-参考:-

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

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