feat(Queue): add spotifyBridge option

This commit is contained in:
DevAndromeda 2021-10-17 13:09:30 +05:45
parent 1d113e3ff8
commit a0badb849d
No known key found for this signature in database
GPG key ID: FA40E3EC5CB6DCD6

View file

@ -639,16 +639,18 @@ class Queue<T = unknown> {
const customDownloader = typeof this.onBeforeCreateStream === "function";
if (["youtube", "spotify"].includes(track.raw.source)) {
let spotifyResolved = false;
if (this.options.spotifyBridge && track.raw.source === "spotify" && !track.raw.engine) {
track.raw.engine = await YouTube.search(`${track.author} ${track.title}`, { type: "video" })
.then((x) => x[0].url)
.catch(() => null);
spotifyResolved = true;
}
const link = track.raw.source === "spotify" ? track.raw.engine : track.url;
if (!link) return void this.play(this.tracks.shift(), { immediate: true });
if (customDownloader) {
stream = (await this.onBeforeCreateStream(track, track.raw.source || "youtube", this)) ?? null;
stream = (await this.onBeforeCreateStream(track, spotifyResolved ? "youtube" : track.raw.source, this)) ?? null;
if (stream)
stream = ytdl
.arbitraryStream(stream, {