discord-music-bot
discord-music-bot copied to clipboard
Error not supporting spotify urls
When I try to put the spotify urls, the module "play-dl" emits an error
Streaming from Spotify is not supported. Please use search() to find a similar track on YouTube or SoundCloud instead.
I used play-dl
in the onBeforeCreateStream
function while creating the queue, from when it caused this error whenever I try to play with spotify urls.
Any help would be appreciated.
the code :
async onBeforeCreateStream(track, source) {
if (track.url.includes('spotify.com')) source = 'spotify';
if (source == 'youtube') return (await playdl.stream(track.url, { discordPlayerCompatibility: true })).stream;
else if (source == "spotify") {
let search = await playdl.search(`${track.title} by ${track.author}`, { source: { youtube: 'video' } }).then(x => x[0].url);
return (await playdl.stream(search, { discordPlayerCompatibility: true })).stream;
}
console.log(track, source);
}