[英]How to mute everyone in a voice channel using discord.js
I have tried to overwrite permissions denying speak but it only applies when members leave and join the vc.我试图覆盖拒绝发言的权限,但它仅适用于成员离开并加入 vc 时。 I have also tried "member.setMute(true)" but it mutes members globally, so they cant speak in any channel and I would like just to mute in one specific channel.
我也尝试过“member.setMute(true)”,但它会使成员在全球范围内静音,因此他们无法在任何频道中发言,我只想在一个特定频道中静音。
Try doing the following:尝试执行以下操作:
voiceChannel.members.forEach(m => {
m.voice.setMute(1).catch(err =>{})
})
Here, it cycles through all the members in voiceChannel
and server-mutes them.在这里,它循环遍历
voiceChannel
中的所有成员并将它们静音。 You can do m.voice.setMute(0)
to unmute them.您可以执行
m.voice.setMute(0)
取消静音。 Additionally, if the command is being sent by a member that's in a specific voice channel, you can replace voiceChannel
with message.member.voice.channel
.此外,如果命令是由特定语音频道中的成员发送的,您可以将
voiceChannel
替换为message.member.voice.channel
。
The catch is important in case it tries to mute someone who is already muted.如果它试图使已经静音的人静音,则捕获很重要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.