From 4c835286bca59839c70048c1f64e12ff4fc0dc51 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Sun, 12 Jan 2020 18:56:11 +0100 Subject: [PATCH] Update disconnect() system --- src/Player.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Player.js b/src/Player.js index a262231..72cd9b0 100644 --- a/src/Player.js +++ b/src/Player.js @@ -270,11 +270,14 @@ class Player { // If there isn't any music in the queue if(queue.songs.length < 2 && !firstPlay){ // Leaves the voice channel - if(this.options.leaveOnEnd) queue.connection.disconnect(); + if(this.options.leaveOnEnd && !queue.stopped) queue.connection.channel.leave(); // Remoces the guild from the guilds list this.queues = this.queues.filter((g) => g.guildID !== guildID); // Emits stop event - if(queue.stopped) return queue.emit('stop'); + if(queue.stopped){ + if(this.options.leaveOnStop) queue.connection.channel.leave(); + return queue.emit('stop'); + } // Emits end event return queue.emit('end'); }