From f7813170de81c262620f6c88df74ca4133ea735d Mon Sep 17 00:00:00 2001 From: DooM <68818349+EwoX07@users.noreply.github.com> Date: Fri, 15 Oct 2021 07:32:58 +0700 Subject: [PATCH] Fix AUTOPLAY it should fix the autoplay mode. autoplay should never ignore a track in a queue and should be triggered when the queue is empty. --- src/Structures/Queue.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index 0116093..044e815 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -189,16 +189,14 @@ class Queue { if (!this.tracks.length && this.repeatMode === QueueRepeatMode.OFF) { if (this.options.leaveOnEnd) this.destroy(); this.player.emit("queueEnd", this); + } else if (!this.tracks.length && this.repeatMode === QueueRepeatMode.AUTOPLAY) { + this._handleAutoplay(Util.last(this.previousTracks)); } else { - if (this.repeatMode !== QueueRepeatMode.AUTOPLAY) { - if (this.repeatMode === QueueRepeatMode.TRACK) return void this.play(Util.last(this.previousTracks), { immediate: true }); - if (this.repeatMode === QueueRepeatMode.QUEUE) this.tracks.push(Util.last(this.previousTracks)); - const nextTrack = this.tracks.shift(); - this.play(nextTrack, { immediate: true }); - return; - } else { - this._handleAutoplay(Util.last(this.previousTracks)); - } + if (this.repeatMode === QueueRepeatMode.TRACK) return void this.play(Util.last(this.previousTracks), { immediate: true }); + if (this.repeatMode === QueueRepeatMode.QUEUE) this.tracks.push(Util.last(this.previousTracks)); + const nextTrack = this.tracks.shift(); + this.play(nextTrack, { immediate: true }); + return; } });