Restart app node.js/js


#1

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.


#2

Hey, WilsontheWolf

Here is the easiest way to do that:

process.exit(1);

My restart bot command:

if (<Message>.content === 'restartthebot') {
  const embed = new Discord.RichEmbed()
    .setTitle('Done.')
    .setDescription(`Restarted in **${Math.floor(client.ping)}**ms`);
  if (message.author.id !== 'Owner's ID') return;
  message.channel.send(embed).then(() => {
  process.exit(1);
})
};

If you are on Discord.js [master] just change RichEmbed to MessageEmbed
Thanks.


#3

Thanks Trying it now


#4

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.

Thanks!
Patrick


#5

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


#6

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!


#7

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


#8

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