You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Natsuki/events/voiceStateUpdate.js

17 lines
1.1 KiB

4 years ago
const Monitor = require('../models/monitor');
module.exports = async (client, oldState, voice) => {
4 years ago
if (client.users.cache.get(voice.member.id).bot) {return;}
if (voice.guild && client.misc.cache.monitEnabled.includes(voice.guild.id)) {
if (voice.channelID) {
client.misc.cache.VCG[voice.member.id] = voice.guild.id;
if (!client.misc.cache.inVC.includes(voice.member.id)) {client.misc.cache.inVC.push(voice.member.id);}
if (!client.misc.cache.activeVC.includes(voice.channelID)) {client.misc.cache.activeVC.push(voice.channelID);}
} else {
if (!client.misc.cache.inVC.includes(voice.member.id)) {return;}
client.misc.inVC.splice(client.misc.inVC.indexOf(voice.member.id), 1);
if (!voice.channel.members.size && client.misc.activeVC.includes(voice.channelID)) {client.misc.activeVC.splice(client.misc.activeVC.indexOf(voice.channelID), 1);}
if (Object.keys(client.misc.cache.VCG).includes(voice.member.id)) {delete client.misc.cache.VCG[voice.member.id];}
}
}
};