Discord reconnect (or reboot) option?


I’ve noticed the bot seems to lose its connection to Discord occasionally. (problem may be on the Discord side) It would be great if there were a bot command I could enter in Twitch chat to force the bot to reconnect to Discord (or even reboot the bot remotely), so I don’t have to manually reboot the bot locally to address connectivity issues.



The bot should reconnect by its own, unless Discord dies and it tries to reconnect 5 times, which is currently the maximum amount of tries. I might increase it to 20 attempts or so.


I find, on about a weekly basis, the bot gets disconnected from Discord in a way that it’s not reconnecting. Could be network issues and connection attempts running out as suggested.

Since the bot seems to do a much better job staying connected to Twitch, having a command we can enter on Twitch to have the bot reconnect on discord would be amazing. Increasing the attempts is good, but if local network difficulties, anything on the route to discord, or discord its self has network issues it’s possible things could still time out of connection attempts are limited without the ability to re-initiate connection attempts. At the same time I get you don’t want the bot endlessly spamming connection attempts, so having a manual trigger would be super handy.

Thanks again for the great support!



I have no idea what type of reconnect limits Discord has, the library handles that for us, and Discord’s documentation isn’t the best, so adding a command could potentially get someone banned if they like spamming it. I changed the reconnect attempts to 50, so that should be good for now. Those attempts follow a logic to make sure we never hit Discord’s limit.


Awesome, thanks.

Good point about introducing the possibility of a user accidentally getting banned by spamming the command!



Just a quick update on this. I’ve noticed that my bot is still disconnecting from discord every few days. I also noticed that the bot fails to reconnect to discord if I reboot my router. Guessing that the retry attempts run out before the router is back up? I did a firmware update on the router that had it down for a couple minutes.

I’m sure the 50 attempt will resolve this. That said, it’s still super frustrating right now that the only way I can get the bot to reconnect is to do a full bot reboot (which will wipe another week-long raffle). Seems like there should be some way to initiate a reconnect that would hopefully not put the user at risk of too many attempts.



I didn’t mention all issues in my previous post, but there are many more with this. Main one being is that, this requires destroying the discord object, then creating a new one, to my knowledge Discord4J doesn’t have a reconnect method. Once the object gets destroyed, the scripts could still try to use the old one (which doesn’t exist) while the new one is being created, and if Discord fails to connect again, it will still be using an object that doesn’t exist, which could lead to many random errors.

I’ll look more into Discord4J and see if they have a reconnect method, but the command would probably be in the console, maybe Twitch chat if needed.


Was added here: https://github.com/PhantomBot/PhantomBot/pull/1784


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.