Answer the question
In order to leave comments, you need to log in
How to display people in voice channels discord js?
Hello, I am writing a people counter on the server and in Voice channels.
I figured out memberCount by checking the box in the bot's personal account. (SERVER MEMBERS INTENT)
But it doesn't work with online voice channels. It remembers the number, and even after the person exits it is not updated, thus this indicator only grows until the bot is restarted. (I also tried to check the PRESENCE INTENT box on the developer portal) Please help, below is the code.
ps for this I have a separate js file.
module.exports = (client) => {
async function members() {
const guild = await client.guilds.fetch("id сервера/гильдии");
let members = guild.memberCount.toLocaleString();
client.channels.cache.get("78677696201306****").setName(`Участники: ${members}`);
}
async function online() {
const guild = await client.guilds.fetch("id сервера/гильдии");
let voiceonline = guild.voiceStates.cache.size.toLocaleString();
console.log(voiceonline);
client.channels.cache.get("80671070358654****").setName(`Voice: ${voiceonline}`);
}
var interval = setInterval(function () {members(), online() }, 600000 );
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question