Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error emitted from the connection: aborted #55

Open
ArthurSouzaC opened this issue Sep 20, 2021 · 9 comments
Open

Error emitted from the connection: aborted #55

ArthurSouzaC opened this issue Sep 20, 2021 · 9 comments

Comments

@ArthurSouzaC
Copy link

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"

@pateckii
Copy link

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.

@ArthurSouzaC
Copy link
Author

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?

@pateckii
Copy link

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;

@pateckii
Copy link

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.

@samusaran
Copy link

@pateckii Your solution seems to work fine!

samusaran pushed a commit to samusaran/discord-music-bot that referenced this issue Sep 21, 2021
@MeTonaTOR
Copy link

MeTonaTOR commented Sep 21, 2021

Better fix than mine for sure, thanks for sharing @pateckii :3

@bbpink217
Copy link

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
Copy link

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!

@Zloka
Copy link

Zloka commented Oct 12, 2021

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? 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants