如何检查语音频道中有多少成员?

发布于 2025-02-13 04:00:38 字数 254 浏览 1 评论 0原文

有没有办法检查语音频道中有多少成员或在Discord.js中为空的成员(V. 13.8.1)?

我已经尝试过

async function usercount(voiceState){
    let users = await(voiceState.channel.fetch.memberCount);
    console.log(users)
}

Is there a way to check how many members are in a voice channel or if it's empty in discord.js (V. 13.8.1)?

I have already tried this

async function usercount(voiceState){
    let users = await(voiceState.channel.fetch.memberCount);
    console.log(users)
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

墨小墨 2025-02-20 04:00:38

是基于语音的频道中成员的集合。集合具有size属性,因此类似的东西应该有效:

function usercount(voiceState) {
  let { members } = voiceState.channel;

  console.log(members);

  return members.size;
}

VoiceChannel#members is a collection of the members in a voice-based channel. Collection's have a size property, so something like this should work:

function usercount(voiceState) {
  let { members } = voiceState.channel;

  console.log(members);

  return members.size;
}
玩物 2025-02-20 04:00:38

可以使用voicechannel.members.size来获取频道中有多少成员。

这是一个例子:

const GuildMember = new Discord.GuildMember(); // This shall be the command author.

if (GuildMember.voice.channel) 
{      
    console.log(GuildMember.voice.channel.members.size);
};

Can use the VoiceChannel.members.size to get how many members are in the channel.

Here's an example:

const GuildMember = new Discord.GuildMember(); // This shall be the command author.

if (GuildMember.voice.channel) 
{      
    console.log(GuildMember.voice.channel.members.size);
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文