Clear command added!

This commit is contained in:
Keyemail 2024-05-10 23:55:44 -07:00
parent 88e5284441
commit fe639cd7bc
2 changed files with 29 additions and 1 deletions

View file

@ -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);
}
}
}

View file

@ -65,7 +65,7 @@ client.on(Events.InteractionCreate, async interaction => {
try { try {
await command.execute(interaction); await command.execute(interaction);
} catch (error) { } 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); console.error(error);
if(interaction.replied || interaction.deferred) { if(interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'Error executing this command! Something went wrong, try again later.', ephemeral: true }); await interaction.followUp({ content: 'Error executing this command! Something went wrong, try again later.', ephemeral: true });