当我更改语音频道中角色的权限时,其中的成员不会被静音。他们需要离开然后重新进入才能被静音。
这是我的一段代码:
cat = ctx.guild.get_channel(categorychannel)
everyone = ctx.guild.default_role
perm = cat.overwrites_for(everyone)
perm.speak = False
channel = await ctx.guild.create_voice_channel("test", category=cat)
await channel.set_permissions(everyone, overwrite=perm)
是否有可能有类似于更新功能的东西?
答案 0 :(得分:0)
我认为这是通过机器人实现的唯一真正方法是将成员移动到另一个 VC,然后再返回。 机器人需要 move_members
权限。
如果您已经设置了一个临时语音通道来将它们移至,那么您可以执行以下操作:
# Bear in mind that the user needs to be in a voice channel for this to work
@bot.command()
async def update(ctx, target: discord.Member):
temp_vc = discord.utils.get(ctx.guild.voice_channels, id=112233445566778899)
prev_vc = target.voice.channel
await target.move_to(temp_vc) # is a coro, therefore needs to be awaited
await target.move_to(prev_vc)
也可以随意添加您想要的任何异常处理。
答案 1 :(得分:0)
经过一些测试,我发现我们可以将成员移动到它更新权限的同一频道。 所以...你可以使用这些功能:
member.move_to(channel)
或
member.edit(voice_channel=channel)