From a5515493b88a3a76d4bcbe46e679a74b367a1bef Mon Sep 17 00:00:00 2001 From: Ecolipsy Date: Sun, 12 Dec 2021 15:56:37 +0100 Subject: [PATCH] Add restart command --- index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/index.js b/index.js index f0114ae..35df8c3 100644 --- a/index.js +++ b/index.js @@ -161,6 +161,10 @@ client.on("ready", () => { required: true } ] + }, + { + name: "restart", + description: "Restarts the bot." } ]).then(cmds => { console.log("Finished loading all commands"); @@ -299,6 +303,12 @@ client.on("interactionCreate", (int) => { int.reply("An unexpected error has occured: ```js\n" + e.stack + "```"); }); }); + } else if(int.commandName == "restart"){ + var devs = readJson("worthy.json"); + if(!devs.devlist.includes(int.user.id)) return int.reply(":x: Access denied"); + int.reply("Restarting...").then(msg => { + process.exit(69420); + }); } } else if(int.isButton()){ if(int.customId.startsWith("cat")){ @@ -326,3 +336,9 @@ client.on("interactionCreate", (int) => { } } }); + + +process.on("exit", (code) => { + console.log("Exiting with code", code); + client.destroy(); +}); \ No newline at end of file