会员的频道权限更新?
Channel permission update for members?
当我更改语音频道中某个角色的权限时,其中的成员不会被静音。他们需要离开然后重新进入才能静音。
这是我的一段代码:
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)
能不能有类似更新功能的东西?
我能看到通过机器人实现这一点的唯一真实方法是将成员移动到另一个 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)
您也可以随意添加您想要的任何异常处理。
参考文献:
经过一些测试,我发现我们可以将成员移动到更新权限的同一频道。
所以...您可以使用这些功能:
member.move_to(channel)
或者
member.edit(voice_channel=channel)
当我更改语音频道中某个角色的权限时,其中的成员不会被静音。他们需要离开然后重新进入才能静音。
这是我的一段代码:
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)
能不能有类似更新功能的东西?
我能看到通过机器人实现这一点的唯一真实方法是将成员移动到另一个 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)
您也可以随意添加您想要的任何异常处理。
参考文献:
经过一些测试,我发现我们可以将成员移动到更新权限的同一频道。 所以...您可以使用这些功能:
member.move_to(channel)
或者
member.edit(voice_channel=channel)