Clear command added!
This commit is contained in:
parent
88e5284441
commit
fe639cd7bc
28
commands/moderation/clear.js
Normal file
28
commands/moderation/clear.js
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
2
main.js
2
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 });
|
||||
|
|
Loading…
Reference in a new issue