From b4dd7cf2df33ab0d3719987bdb6936d38e45c88c Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Sun, 12 Jan 2020 20:14:26 +0100 Subject: [PATCH] Update leaveOnEmpty system --- src/Player.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Player.js b/src/Player.js index 01091dd..6947a03 100644 --- a/src/Player.js +++ b/src/Player.js @@ -60,16 +60,16 @@ class Player { client.on('voiceStateUpdate', (oldState, newState) => { if(!this.options.leaveOnEmpty) return; // If the member leaves a voice channel - if(oldState.channel && !newState.channel) return; + if(!oldState.channelID || newState.channelID) return; // Search for a queue for this channel - let queue = this.queues.find((g) => g.connection.channel.id === oldState.channel.id); + let queue = this.queues.find((g) => g.connection.channel.id === oldState.channelID); if(queue){ // Disconnect from the voice channel queue.connection.channel.leave(); // Delete the queue this.queues = this.queues.filter((g) => g.guildID !== queue.guildID); // Emit end event - this.emit('channelEmpty'); + queue.emit('channelEmpty'); } }); }