So my discord bot work perfectly when launch from my computer but when it run from glitch.com he instantly disconnect from vocal channel.
i got this error :
(node:15486) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:1988
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
(node:15486) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15486) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:15486) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:1988
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
(node:15486) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
Unfortunately that information doesn’t give us much to go on - those are pretty generic “OMG something’s wrong and you’re not doing anything about it!” messages. However the ECONNREFUSED message leads me to believe that perhaps you’ve got the debugger running and that’s causing you some problems.
If you open your Logs pane by clicking on the “Logs” button under your project’s name do you see a little stop sign icon: ? If so, what happens if you click on it?
@cori Yeah sorry i was in a quick rush when i first wrote my message.
I figured out what was giving me that error and i fixed it but i still have the problem from the bot instantly disconnecting from the vocal channel which mean that my playStream is instantly ending without given reason :
const dispatcher = serverQueue.connection.playStream(ytdl(song.url))
.on('end', reason => {
if (reason === 'Stream is not generating quickly enough.') console.log('Song ended.');
else console.log(reason+ " : b");
serverQueue.songs.shift();
play(guild, serverQueue.songs[0]);
})
Ok I don’t know a ton about discord bots, so hopefully someone who knows more can chip in here, but what I believe I can ascertain from what you posted is that your callback isn’t actually returning a reason.
If you can tell us your project name, or even the discord library you’re using, we might be able to find out something more useful.
Well no what you are proposing to me, solve an other bug only happening in an async scope and only when he is called directly after another call.
My problem is that playStream(ytdl(song.url)) instantly end even on first call.
.on('end' ()=>{})
execute his code only when he catch the event ‘end’ who is emitted by playStream() when he finished to send the stream. (actually he execute it directly only because my problem occured )
Okay i found the origin of the problem :
playStream() need ffmpeg-binaries to be able to stream the audio on the connection.
ffmpeg-binaries need to be installed(downloaded and build) with the host console using
npm install -g ffmpeg-binaries
which can’t be done because we don’t have enought permission.
So the only hope is that someone from staff of glitch.com see this and try to fix the issue for everyone or install it in my project from a console with enought permission.
The -g flag has no effect in Glitch; packages are installed in the shared pnpm volume by default.
What do you see if you run enable-pnpmn in the console? When I add ffmpeg-binaries":"*" to my package.json in a new project and then subsequently run pnpm list in the console I see thoat package installed. Perhaps triggering a reinstall by using enable-pnpm will install that package for your use and you can see if that resolves the issue.
In this case you’ll probably want the full-screen console in case there’s an error message on install; you can access that by opening the Project Name menu, selecting Advanced Options, and then selecting Open Console.
@cori
ffmpeg-binaries was already in package.js changin is version from “^4.0.0” to “*” did nothing exept making glitch interface asking me to put it to “^4.0.0” again.
Else thank you the command enable-pnpm solved the issue by forcing ffmpeg-binaries to be build.
Great! By referencing “*” in the version I just mean that when I tried it out in my package.json I didn’t care which version was being installed - I didn’t expect that to resolve the problem; sorry I wasn’t more clear.
Glad you’ve gotten past that hurdle! Happy Glitching!