diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index a533878..3208a24 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -143,7 +143,7 @@ class Queue { this.connection.on("start", (resource) => { this.playing = true; - if (!this._filtersUpdate) this.player.emit("trackStart", this, resource.metadata); + if (!this._filtersUpdate) this.player.emit("trackStart", this, resource?.metadata ?? this.current); this._filtersUpdate = false; }); @@ -151,7 +151,7 @@ class Queue { this.playing = false; if (this._filtersUpdate) return; this._streamTime = 0; - this.previousTracks.push(resource.metadata); + if (resource) this.previousTracks.push(resource.metadata); if (!this.tracks.length && this.repeatMode === QueueRepeatMode.OFF) { if (this.options.leaveOnEnd) this.destroy(); @@ -385,6 +385,9 @@ class Queue { return await this.play(prev, { immediate: true }); } + /** + * Clear this queue + */ clear() { this.#watchDestroyed(); this.tracks = []; @@ -457,6 +460,11 @@ class Queue { }); } + /** + * Private method to handle autoplay + * @param {Track} track The source track to find its similar track for autoplay + * @returns {Promise} + */ private async _handleAutoplay(track: Track): Promise { this.#watchDestroyed(); if (!track || ![track.source, track.raw?.source].includes("youtube")) {