From ea8108979ba2956c2abbfd637105b96038aeb128 Mon Sep 17 00:00:00 2001 From: DevAndromeda <46562212+DevAndromeda@users.noreply.github.com> Date: Mon, 6 Sep 2021 21:53:07 +0545 Subject: [PATCH] fix(Queue): fix createStream --- src/Structures/Queue.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index 0bbb1fe..d604724 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -645,16 +645,18 @@ class Queue { if (!link) return void this.play(this.tracks.shift(), { immediate: true }); if (customDownloader) { - stream = ytdl - .arbitraryStream(await this.createStream(track, link), { - opusEncoded: false, - fmt: "s16le", - encoderArgs: options.encoderArgs ?? this._activeFilters.length ? ["-af", AudioFilters.create(this._activeFilters)] : [], - seek: options.seek ? options.seek / 1000 : 0 - }) - .on("error", (err) => { - return err.message.toLowerCase().includes("premature close") ? null : this.player.emit("error", this, err); - }); + stream = (await this.createStream(track, link)) ?? null; + if (stream) + stream = ytdl + .arbitraryStream(stream, { + opusEncoded: false, + fmt: "s16le", + encoderArgs: options.encoderArgs ?? this._activeFilters.length ? ["-af", AudioFilters.create(this._activeFilters)] : [], + seek: options.seek ? options.seek / 1000 : 0 + }) + .on("error", (err) => { + return err.message.toLowerCase().includes("premature close") ? null : this.player.emit("error", this, err); + }); } else { stream = ytdl(link, { ...this.options.ytdlOptions, @@ -668,8 +670,9 @@ class Queue { }); } } else { - const arbitrarySource = customDownloader - ? await this.createStream(track, track.raw.source || track.raw.engine) + const tryArb = (customDownloader && (await this.createStream(track, track.raw.source || track.raw.engine))) || null; + const arbitrarySource = tryArb + ? tryArb : track.raw.source === "soundcloud" ? await track.raw.engine.downloadProgressive() : typeof track.raw.engine === "function"