fix(Queue): fix createStream

This commit is contained in:
DevAndromeda 2021-09-06 21:53:07 +05:45
parent 38c0e209a0
commit ea8108979b
No known key found for this signature in database
GPG key ID: FA40E3EC5CB6DCD6

View file

@ -645,16 +645,18 @@ class Queue<T = unknown> {
if (!link) return void this.play(this.tracks.shift(), { immediate: true }); if (!link) return void this.play(this.tracks.shift(), { immediate: true });
if (customDownloader) { if (customDownloader) {
stream = ytdl stream = (await this.createStream(track, link)) ?? null;
.arbitraryStream(await this.createStream(track, link), { if (stream)
opusEncoded: false, stream = ytdl
fmt: "s16le", .arbitraryStream(stream, {
encoderArgs: options.encoderArgs ?? this._activeFilters.length ? ["-af", AudioFilters.create(this._activeFilters)] : [], opusEncoded: false,
seek: options.seek ? options.seek / 1000 : 0 fmt: "s16le",
}) encoderArgs: options.encoderArgs ?? this._activeFilters.length ? ["-af", AudioFilters.create(this._activeFilters)] : [],
.on("error", (err) => { seek: options.seek ? options.seek / 1000 : 0
return err.message.toLowerCase().includes("premature close") ? null : this.player.emit("error", this, err); })
}); .on("error", (err) => {
return err.message.toLowerCase().includes("premature close") ? null : this.player.emit("error", this, err);
});
} else { } else {
stream = ytdl(link, { stream = ytdl(link, {
...this.options.ytdlOptions, ...this.options.ytdlOptions,
@ -668,8 +670,9 @@ class Queue<T = unknown> {
}); });
} }
} else { } else {
const arbitrarySource = customDownloader const tryArb = (customDownloader && (await this.createStream(track, track.raw.source || track.raw.engine))) || null;
? await this.createStream(track, track.raw.source || track.raw.engine) const arbitrarySource = tryArb
? tryArb
: track.raw.source === "soundcloud" : track.raw.source === "soundcloud"
? await track.raw.engine.downloadProgressive() ? await track.raw.engine.downloadProgressive()
: typeof track.raw.engine === "function" : typeof track.raw.engine === "function"