Answer the question
In order to leave comments, you need to log in
Get the number of members in a voice channel (discord.js12)?
How can I find out the number of users in a voice channel? I have a system that counts the time of users in the voice channel, I want it to work, if there are more than two people in the voice channel, please tell me.
The code:
exports.execute = async (oldState, newState) => {
if ((oldState.member && oldState.member.user.bot) || (newState.member && newState.member.user.bot)) {
return;
}
if (!oldState.channelID && newState.channelID) {
Activites.set(oldState.id, Date.now());
}
let data;
if (!Activites.has(oldState.id)) {
data = Date.now();
Activites.set(oldState.id, data);
}
else {
data = Activites.get(oldState.id);
}
let duration = Date.now() - data;
if (oldState.channelID && !newState.channelID) {
Activites.delete(oldState.id);
vt.add(`stats.${oldState.guild.id}.${oldState.id}.channels.${oldState.channelID}`, duration);
vt.set(`stats.${oldState.guild.id}.${oldState.id}.activity`, Date.now());
}
else if (oldState.channelID && newState.channelID) {
Activites.set(oldState.id, Date.now());
vt.add(`stats.${oldState.guild.id}.${oldState.id}.channels.${oldState.channelID}`, duration);
vt.set(`stats.${oldState.guild.id}.${oldState.id}.activity`, Date.now());
}
};
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