Reputation: 45
I want to make a command so when I do !reset it will reboot/restart the bot. I am using Discord.js v12.
This bot is a simple moderation bot for a server so I just want a quick command to fix errors that require a quick restart without going into Heroku and restart it from there.
Upvotes: 0
Views: 8494
Reputation: 42
To restart your bot you shall destroy the Client and call the login() method.
client.destroy();
client.login(process.env.token);
Example:
if (command === "reset") {
if (message.author.id !== "Your ID Here") return false;
message.reply("Resetting...");
client.destroy();
client.login(process.env.token);
};
Upvotes: 0
Reputation: 499
I'd imagine you'd need to call the Heroku API to restart the service.
https://devcenter.heroku.com/articles/platform-api-reference#dyno-restart
Upvotes: 1