Managing a Discord server of any size 24/7 has its own set of challenges. One of the things that make managing such server much easier and less time-consuming is using Discord bots.
There are literally hundreds, if not thousands of Discord bots in the wild. They will not only help you manage your server without spending too much time and effort, but also make your server more professional, and take it to the next level.
Some of the Discord bots are hosted, which means you can simply invite it to your server and nothing else. A few other bots are self-hosted, which you must set them up manually in an always-on machine, like a VPS or your home lab server.
In the past, we've covered a list of the best open source Discord bots, as well as Discord spam bots to stress-test them. In this article, we will show you a few things you can do if your self-hosted Discord bot gone offline or irresponsive.
Restart your VPS or server
This is probably the oldest answer in the computer history. When anything goes wrong, restart the machine will does the trick most of the time (except when it doesn't, of course).
If you're using Windows or Mac, use the graphical interface to force a restart.
If you're using Linux, there's a high chance that it's a server or VPS and doesn't come with a graphical interface. Instead, you can force a restart on Linux with the following command :
sudo reboot # OR sudo shudown -r now
Check if the bot is running
In case the restart doesn't help, you should continue to check whether the bot is actually running. Most of the modern Discord bots use Discord.js as a framework, so you have to inspect running processes to see if
node was there.
On Linux, use the following command to get the list of all running processes and filter out anything related to
ps aux | grep node
If nothing comes out, you might have to run
npm start to start your Discord bot again. Consult your bot documentation to know how to do it.
Install the bot as a daemon
Most of the self-hosted Discord bots come with an installation script which installs the bots as a daemon so that it can run 24/7 without the user keeping the SSH session open.
If your bot uses Discord.js at its core, it is a Node.js app. Therefore, you can follow the steps in PM2 part of DigitalOcean excellent guide on How To Set Up a Node.js Application for Production to create a daemon for the Discord bot.
A few Discord bots use discord.py instead of Discord.js. Similarly, you can keep the bot alive by create a
systemd daemon for it,
nohup the bot or run it in a separate
screen session. An useful guide on each of the options is on GalaxyGate Wiki.
Those are just some generic suggestions, in order to be able to advise you further, we would need some more details regarding your specific setup. There could be an error on the server side, the code or hardware. Also, seek help from your bot's official Discord server, there might be someone with experience is able to help.