From 8978a39321d918ba38f9dad175d4bdee81161eaa Mon Sep 17 00:00:00 2001 From: Taken Date: Sun, 2 Apr 2023 10:23:00 +0200 Subject: [PATCH] Adding reload command --- commands/devel.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/commands/devel.js b/commands/devel.js index e7f8a0b..86847cd 100644 --- a/commands/devel.js +++ b/commands/devel.js @@ -17,6 +17,10 @@ module.exports = { subcommand .setName('dbclearnonguildmembers') .setDescription('Clears the database of non-guild members.')) + .addSubcommand(subcommand => + subcommand + .setName('reload') + .setDescription('Reload the bot.')) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDMPermission(false), @@ -53,5 +57,26 @@ module.exports = { } + if (subcommand === 'reload') { + + await interaction.deferReply({ ephemeral: true }) + + const spawn = require('child_process').spawn; + + if (user.id !== dev) { + await interaction.editReply({ content: 'Due to you not screwing something up this command is restricted to only ' + userMentioned, ephemeral: true }) + return + } + + const child = spawn('pm', ['restart 0'], {}) + + if (child.stderr) { + await interaction.editReply({ content: 'Error restarting bot.', ephemeral: true }) + return + } + + await interaction.editReply({ content: 'Restarting bot...', ephemeral: true }) + + } } }; \ No newline at end of file