discord-music-bot
discord-music-bot copied to clipboard
Error emitted from the connection: aborted
First, the bot could connect to voice channel but couldn't play anything I fixed it using this
Now, bot joins voice channel, starts playing and, after a few seconds, stops playing. Node.js log: "Error emitted from the connection: aborted"
It's a known problem with ytdl module. You can try to use play-dl module instead. For me it fixed all of the problems.
It's a known problem with ytdl module. You can try to use play-dl module instead. For me it fixed all of the problems.
how do i change this? directly into discord-player code?
You need to install dev version of discord-player and also play-dl package: cd to main folder with bot then
npm install discord-player@dev
npm install play-dl
In my case every command was a separate .js file, so I edited play.js (play command): add this at the beginning of .js file
const playdl = require("play-dl");
then you find the queue section:
const queue = await client.player.createQueue( guild, {
metadata: channel
});
and after that you paste:
if(!queue.createStream) {
queue.createStream = async (track, source, _queue) => {
if (source === "youtube") {
return (await playdl.stream(track.url, process.env.COOKIES)).stream;
}
};
}
The process.env.COOKIES
is optional. If you want to use your YouTube cookie then add COOKIES="cookie-here"
to your .env file. If you dont want to use cookie, then the return
line should look like this:
return (await playdl.stream(track.url)).stream;
It also might be a problem with age restricted videos. That's why it's good to use cookie. If you want to play age restricted videos then you'll have to add cookie when you're logged in on YouTube and also edit few files of play-dl module.
@pateckii Your solution seems to work fine!
Better fix than mine for sure, thanks for sharing @pateckii :3
Thanks for sharing this fix with a different module @pateckii !!! It's super helpful :D On a side note: Would any of y'all know how to get Spotify to work alongside YouTube with play-dl? I see the option is available with the module but I'm having some trouble modifying the code to have the bot play Spotify playlists. Any tips or ideas on how to get this to work is appreciated! And if by some miracle I figure it out I'll definitely share!
Thanks for sharing this fix with a different module @pateckii !!! It's super helpful :D On a side note: Would any of y'all know how to get Spotify to work alongside YouTube with play-dl? I see the option is available with the module but I'm having some trouble modifying the code to have the bot play Spotify playlists. Any tips or ideas on how to get this to work is appreciated! And if by some miracle I figure it out I'll definitely share!
Oh and for context I already authorized codes for Spotify!
Thanks for sharing this fix with a different module @pateckii !!! It's super helpful :D On a side note: Would any of y'all know how to get Spotify to work alongside YouTube with play-dl? I see the option is available with the module but I'm having some trouble modifying the code to have the bot play Spotify playlists. Any tips or ideas on how to get this to work is appreciated! And if by some miracle I figure it out I'll definitely share!
@bbpink217 You didn't happen to find a solution that also works for Spotify? 🙂