From befbbd5f8ffdfa11df2c660631952f6403821584 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Thu, 27 Jan 2022 13:28:44 -0700 Subject: [PATCH] restart cmd --- commands/dev/restart.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 commands/dev/restart.js diff --git a/commands/dev/restart.js b/commands/dev/restart.js new file mode 100644 index 0000000..5a76cfb --- /dev/null +++ b/commands/dev/restart.js @@ -0,0 +1,35 @@ +const Discord = require('discord.js'); +const cp = require('child_process'); + +module.exports = { + name: "restart", + aliases: ['res'], + meta: { + category: 'Developer', + description: "Fully restart Natsuki", + syntax: '`restart`', + extra: null + }, + help: "Fully restarts the bot. Developer-only.", + async execute(message, msg, args, cmd, prefix, mention, client) { + if (!client.developers.includes(message.author.id)) { + try { + await require('../../util/lxp/cacheloop')(client); + await require('../../util/vcloop')(client); + await require('../../util/monitorloop')(client); + await message.channel.send("Cache synchronized with DB! Restarting..."); + return cp.exec("pm2 restart natsuki", function(error, stdout, stderr) { + if (error) { + return message.channel.send({embeds: [new Discord.MessageEmbed() + .setTitle("Error") + .setDescription(`\`\`\`${error}\`\`\``) + .setColor("ff446a") + .setFooter({text: "Natsuki", iconURL: client.user.avatarURL()}) + .setTimestamp()]} + ); + } + }); + } catch {return message.channel.send("There was an error in trying to do that!");} + } + } +}; \ No newline at end of file