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

bot.connect() not working in a timeout

Open Smiche opened this issue 6 years ago • 1 comments

Calling bot.connect() in a timeout after the bot has been disconnected doesn't reconnect it back. It can still write messages to the server but not receive.

Not sure if that is the normal behaviour due to the discord protocols, but it can be quite mystic trying to figure out why the bot wasn't reconnecting.

// Automatically reconnect if the bot disconnects due to inactivity
bot.on('disconnect', function(erMsg, code) {
  setTimeout(()=>{
    bot.connect();
  }, 1000);
});

Smiche avatar Jun 08 '18 07:06 Smiche

try logging erMsg and code, they might give insight into what's going on

also, are you using the community fork or izy's original version?

cloudrac3r avatar Jun 08 '18 08:06 cloudrac3r