diff --git a/package.json b/package.json index e91dcea..3422176 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord-player-play-dl", - "version": "5.3.10", + "version": "5.3.11", "description": "Complete framework to facilitate music commands using discord.js and play-dl", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index ad0eec0..1ebda6c 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -628,11 +628,20 @@ class Queue { const hasCustomDownloader = typeof this.onBeforeCreateStream === "function"; if (["youtube", "spotify", "soundcloud"].includes(track.raw.source)) { + + let spotifyResolved = false; + if (track.raw.source === "spotify" && !track.raw.engine) { + track.raw.engine = await play.search(`${track.author} ${track.title}`, { limit: 5 }) + .then(res => res[0].url) + .catch(Util.noop); + spotifyResolved = true; + } + const url = track.raw.source === "spotify" ? track.raw.engine : track.url; if (!url) return void this.play(this.tracks.shift(), { immediate: true }); if (hasCustomDownloader) { - stream = (await this.onBeforeCreateStream(track, "youtube", this)) || null; + stream = (await this.onBeforeCreateStream(track, spotifyResolved ? "youtube" : track.raw.source, this)) || null; } if (!stream) {