Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

Bot sometimes works #283

Open
githubuser1102 opened this issue Aug 14, 2018 · 10 comments
Open

Bot sometimes works #283

githubuser1102 opened this issue Aug 14, 2018 · 10 comments

Comments

@githubuser1102
Copy link

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

@cloudrac3r
Copy link

cloudrac3r commented Aug 14, 2018

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

@githubuser1102
Copy link
Author

Yes, installed a few days ago.

@cloudrac3r
Copy link

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

@githubuser1102
Copy link
Author

Ok thanks

@cloudrac3r
Copy link

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

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

@githubuser1102
Copy link
Author

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

@bradnak
Copy link

bradnak commented Aug 19, 2018

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();
}

@githubuser1102
Copy link
Author

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

@githubuser1102
Copy link
Author

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

Never mind, lucky try.

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

No branches or pull requests

3 participants