client.on('voiceStateUpdate', (oldState, newState) => { let mainChannel = '877196900284108821'; if (newState.channelId === mainChannel) { console.log(oldState.member.id + " joined the queue VC."); if (test.length > 0) { newState.disconnect(); // Run makeChannel } else { test.push(oldState.member.id); } } else if (oldState.channelId === mainChannel){ console.log(oldState.member.id + " disconnected from the queue VC."); for( var i = 0; i < test.length; i++){ if (test[i] === oldState.member.id) { test.splice(i, 1); i--; } } } else { console.log("Some other VC stuff happened."); } });