From d783da4b83ec32285c19318425d2bf334d6f79b9 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 19 Feb 2023 20:34:22 -0500 Subject: [PATCH] Consolidated to setup command --- slash-commands/reset.js | 26 -------------------------- slash-commands/setup.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 26 deletions(-) delete mode 100755 slash-commands/reset.js diff --git a/slash-commands/reset.js b/slash-commands/reset.js deleted file mode 100755 index 9744d8e..0000000 --- a/slash-commands/reset.js +++ /dev/null @@ -1,26 +0,0 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); -const fn = require('../modules/functions.js'); -const strings = require('../data/strings.json'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('reset') - .setDescription('Reset all message assignments in your server') - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), - execute(interaction) { - interaction.deferReply({ ephemeral: true }).then(() => { - fn.reset(interaction).then(res => { - interaction.editReply(fn.builders.embed(strings.status.reset)).catch(err => { - console.error(err); - }); - }).catch(err => { - console.error(err); - interaction.editReply(strings.status.resetError).catch(err => { - console.error(err); - }); - }); - }).catch(err => { - console.error(err); - }); - }, -}; \ No newline at end of file diff --git a/slash-commands/setup.js b/slash-commands/setup.js index 4feb841..5e5cbae 100755 --- a/slash-commands/setup.js +++ b/slash-commands/setup.js @@ -39,6 +39,15 @@ module.exports = { .addSubcommand(sc => sc.setName('view') .setDescription('View your server\'s configuration')) + .addSubcommand(sc => + sc.setName('reset') + .setDescription('Remove all server configuration from the database') + .addBooleanOption(o => + o.setName('confirm') + .setDescription('WARNING THIS IS IRREVERSIBLE') + .setRequired(true) + ) + ) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), async execute(interaction) { await interaction.deferReply({ ephemeral: true }); @@ -87,6 +96,27 @@ module.exports = { await interaction.editReply(fn.builders.errorEmbed("There was an error running the command.")); } break; + case "reset": + if (interaction.client.guildInfos.has(interaction.guildId)) { + let guildInfo = interaction.client.guildInfos.get(interaction.guildId); + if (interaction.options.getBoolean('confirm')) { + fn.reset(interaction).then(res => { + interaction.editReply(fn.builders.embed(strings.status.reset)).catch(err => { + console.error(err); + }); + }).catch(err => { + console.error(err); + interaction.editReply(strings.status.resetError).catch(err => { + console.error(err); + }); + }); + } else { + await interaction.editReply(fn.builders.embed("You must select 'true' to confirm setup reset. No changes have been made.")).catch(e => console.error(e)); + } + } else { + throw "Guild doesn't exist in database!"; + } + break; default: await interaction.editReply(fn.builders.errorEmbed(strings.error.invalidSubcommand)).catch(e => console.error(e)); break;