解锁命令覆盖不和谐私网通道



我的discord服务器有一堆私人通道,只有角色"验证"的人才能使用。可以访问。我的unlock命令有一个参数,通过将每个通道的权限设置为send_messages = True来解锁服务器中的每个通道,因此根据这个逻辑,当我使用

命令时,即使@everyone角色也能够访问私有通道代码:

@client.slash_command(name='unlock', guild_ids=[insert guild id here])
@commands.has_permissions(manage_channels = True)
async def unlock(ctx, channel : discord.TextChannel=None, setting = None):
if setting == 'server':
for channel in ctx.guild.channels:
await channel.set_permissions(ctx.guild.default_role, send_messages = True, reason = f'{ctx.author.name} unlocked {channel.name} with --server')
await ctx.respond(f'{ctx.author} unlocked the entire server')
if channel is None:
channel = ctx.message.channel
else:
await channel.set_permissions(ctx.guild.default_role, send_messages = True, reason = f'{ctx.author.name} unlocked {channel.name}')
await ctx.respond(f'unlocked {ctx.channel.mention}')

我试着添加一个命令,可以重新添加私有通道的前缀,并可以编辑已经存在的通道的权限,所以如果你有一个全局通道,你可以使它私有。我希望它能做到这一点,但它却创建了全新的私有通道

设置send_messages并不意味着通道视图访问,它们是断开连接的权限(view_channel控制这一点)。

设置/取消设置消息发送而不暴露隐藏通道是安全的。但是要注意,以这种方式锁定所有通道将导致每个人都无法发送消息,除非他们有administrator权限,或者通道覆盖来发送消息。

最新更新