Restart app node.js/js

Hello there. I am working on a disord.js bot and I want a command that allows me to shut the bot down and have it automatically. If there was any change in code I would like it to update. I hovever cannot find a way to do this. I am ok downloading a new Node.js application if needed. If someone can find this what would a watch.json look like that doesn’t change at all.

1 Like

Hey, WilsontheWolf

Here is the easiest way to do that:


My restart bot command:

if (message.content === 'restartthebot') {
  if ( !== 'Owners ID') return;'Restarted.').then(() => {

Thanks and cheers!

1 Like

Thanks Trying it now

Is your project public? I’m interested in what you’re doing but have no context … would love to take a peek. If not public, no worries.


wilsonmusictest is where I have put it in. I am making a discord music bot and sometimes it needs to reboot

That’s really interesting - a kind of use case I wasn’t aware I could handle on glitch (and didn’t know where you meant until I saw it in server.js). Thanks!

1 Like

Bumb :grimacing:. This only shuts down the bot, doesn’t actually restart it.

You can use the refresh command in the console to restart your project.


This Should Work:

const Discord = require(‘discord.js’);
const client = new Discord.Client();
const settings = {
token: ‘YOUR - TOKEN - HERE’,
prefix: ‘YOUR - PREFIX - HERE’,
client.on(‘message’, message => {
if (message.content === ${settings.prefix}restart) {
const embed = new Discord.RichEmbed()
.setDescription(Restarted in: **${Math.floor(}**ms);
if ( !== ‘YOUR-ID-HERE’) {
const NotAllowedEmbed = new Discord.RichEmbed()
.setDescription(You Cannot Restart ${client.user.tag}!);;
.then(() => client.destroy())
.then(() => client.login(settings.token));

.then(() => client.login(YOUR-TOKEN-HERE));
or see my other comment :wink:

this would destroy the client but not reload the code. if you have glitch process.exit shuts down the bot and glitch starts back up again. If you want this on a non-glitch bot use pm2