简体   繁体   English

显示用户连接到语音通道?

[英]Show users connected to voice channel?

I want to know is it possible to know if any member is connected to a any voice channel in discord.js v12.2.0.我想知道是否有可能知道是否有任何成员连接到 discord.js v12.2.0 中的任何语音通道。 Please let me know if you have any clues on it.如果您对此有任何线索,请告诉我。

Use VoiceChannel.members使用VoiceChannel.members

const vc = <message>.guild.channels.cache.get('VC Id')
const members = vc.members //COLLECTION

To check if a member is in vc, use GuildMember.voice要检查成员是否在 vc 中,请使用GuildMember.voice

const vc = <member>.voice.channel //VOICE CHANNEL
//if you want, you can check the vc name, id, etc with vc.name, vc.id, etc

EDIT编辑
Here is an example for what you said in the comments这是您在评论中所说的示例

//MAKE SURE IT IS ASYNC CALLBACK
await client.guilds.fetch();
const VCs = [];
client.guilds.cache.forEach(async guild => {
await guild.channels.fetch();
let VCs = guild.channels.cache.filter(c => c.type === 'voice');
VCs.forEach(vc => {
if(vc.members) {
VCs.push(vc)
}
})
})

I hope this is what you wanted ( VCs is an array with all VCs with members)我希望这是你想要的( VCs是一个包含所有 VC 成员的数组)

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

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