Answer the question
In order to leave comments, you need to log in
How to count the time spent in a voice channel?
I have a code that reacts to voice entry and exit. At the entrance it is written "who and where joined", at the exit "who came from where". How can I change it so that it also counts the time spent in the voice channel?
global.bot.on('voiceStateUpdate', (oldState, newState) => {
const date = new Date();
const member = newState.member;
const currenttime = `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
const oldchan = oldState.channel;
const newchan = newState.channel;
if (newchan != oldchan) {
if (oldchan) {
if (newchan) {
console.log(`${currenttime} - ${member.nickname || member.user.username} сменил канал с ${oldchan.name} на ${newchan.name}`);
}
else {
console.log(`${currenttime} - ${member.nickname || member.user.username} ушёл ${oldchan.name}`);
}
}
else if (newchan) {
console.log(`${currenttime} - ${member.nickname || member.user.username} присоединился ${newchan.name}`);
}
}
});
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