Update disconnect() system

This commit is contained in:
Androz2091 2020-01-12 18:56:11 +01:00
parent ae264426c6
commit 4c835286bc

View file

@ -270,11 +270,14 @@ class Player {
// If there isn't any music in the queue // If there isn't any music in the queue
if(queue.songs.length < 2 && !firstPlay){ if(queue.songs.length < 2 && !firstPlay){
// Leaves the voice channel // 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 // Remoces the guild from the guilds list
this.queues = this.queues.filter((g) => g.guildID !== guildID); this.queues = this.queues.filter((g) => g.guildID !== guildID);
// Emits stop event // 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 // Emits end event
return queue.emit('end'); return queue.emit('end');
} }