discord.io icon indicating copy to clipboard operation
discord.io copied to clipboard

Bot sometimes works

Open githubuser1102 opened this issue 5 years ago • 10 comments

Sometimes when I do node bot.js it waits at least 5-7 seconds then starts and everything works fine. But sometimes I do it and it starts really fast, and it's detecting stuff in Command Prompt, but is outputting nothing to Discord. This includes the bot's presence (says online but not playing anything) and sending messages. When it does this when I'm running manually to test, I just CTRL+C then up arrow then enter to re-run. But on Heroku, where it restarts every once in a while, I can't control whether it does it correctly or not. Any help is appreciated.

I am on Windows 7 running bot normally from Command Prompt

githubuser1102 avatar Aug 14 '18 00:08 githubuser1102

Are you using the gateway v6 community fork? (Woor/discord.io)

cloudrac3r avatar Aug 14 '18 01:08 cloudrac3r

Yes, installed a few days ago.

githubuser1102 avatar Aug 14 '18 01:08 githubuser1102

I've never heard of this happening before. Maybe join the support server and ask there? https://discord.gg/0MvHMfHcTKVVmIGP

cloudrac3r avatar Aug 14 '18 01:08 cloudrac3r

Ok thanks

githubuser1102 avatar Aug 14 '18 01:08 githubuser1102

For future readers, the solution was to add a disconnect listener.

bot.on("disconnect", () => {
    bot.connect();
});

cloudrac3r avatar Aug 15 '18 02:08 cloudrac3r

Apparently the solution was not to add a disconnect listener. Sorry future readers, still an issue!

githubuser1102 avatar Aug 15 '18 03:08 githubuser1102

As a troubleshooting step, try changing your disconnect handler to this. It will print an error code and an error message to the console when it disconnects.

bot.on('disconnect', function(errMsg, code) {
    console.log(`Disconnected from Discord. Error Code ${code}. Message ${errMsg}.`
    bot.connect();
}

bradnak avatar Aug 19 '18 00:08 bradnak

Hmm, I tried that but nothing gets outputted into the console. Wondering if it's not picking it up as a disconnect.

githubuser1102 avatar Aug 19 '18 20:08 githubuser1102

Also your code was missing a ( and a );, so I think I fixed that with

bot.on('disconnect', function(errMsg, code) {
    console.log(`Disconnected from Discord. Error Code ${code}. Message ${errMsg}.`);
    bot.connect();
});

githubuser1102 avatar Aug 20 '18 00:08 githubuser1102

Never mind, lucky try.

githubuser1102 avatar Aug 27 '18 02:08 githubuser1102