From fe639cd7bc8906166b12d1cfc07a0f6574e3e55c Mon Sep 17 00:00:00 2001 From: Keyemail Date: Fri, 10 May 2024 23:55:44 -0700 Subject: [PATCH] Clear command added! --- commands/moderation/clear.js | 28 ++++++++++++++++++++++++++++ main.js | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 commands/moderation/clear.js diff --git a/commands/moderation/clear.js b/commands/moderation/clear.js new file mode 100644 index 0000000..d24df56 --- /dev/null +++ b/commands/moderation/clear.js @@ -0,0 +1,28 @@ +const { SlashCommandBuilder } = require('discord.js'); + +const informationStatus = "[INFO]: "; +const warningStatus = "[WARNING]: "; +const errorStatus = "[ERROR]: "; + +module.exports = { + data: new SlashCommandBuilder() + .setName('clear') + .setDescription('Clears a certain amount of text!') + .addNumberOption(option => + option.setName('amount') + .setDescription('Set the amount to clear!') + .setRequired(true)), + async execute(interaction) { + const amount = interaction.options.getNumber('amount'); + + if(amount == isNaN() && amount <= 0) return interaction.channel.message('<:xmark:1238738768563933244> This is not a valid number!'); + + try { + await interaction.channel.bulkDelete(amount); + interaction.channel.send(`<:checkmark:1238736677942460438> Deleted ${amount} of messages!`); + } catch (error) { + console.log(errorStatus + "Something went wrong while trying to clear messages! Debug information is below."); + console.error(error); + } + } +} diff --git a/main.js b/main.js index cf6854b..3f0461a 100644 --- a/main.js +++ b/main.js @@ -65,7 +65,7 @@ client.on(Events.InteractionCreate, async interaction => { try { await command.execute(interaction); } catch (error) { - console.console(errorStatus + "Something went wrong while executing this command! Please use the information below and sudmit to the author of the issue!"); + console.log(errorStatus + "Something went wrong while executing this command! Please use the information below and sudmit to the author of the issue!"); console.error(error); if(interaction.replied || interaction.deferred) { await interaction.followUp({ content: 'Error executing this command! Something went wrong, try again later.', ephemeral: true });