Clear command patches and new npm packages
This commit is contained in:
parent
fe639cd7bc
commit
4728209002
|
@ -1,9 +1,11 @@
|
|||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require('discord.js');
|
||||
|
||||
const informationStatus = "[INFO]: ";
|
||||
const warningStatus = "[WARNING]: ";
|
||||
const errorStatus = "[ERROR]: ";
|
||||
|
||||
const wait = require('node:timers/promises').setTimeout;
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('clear')
|
||||
|
@ -15,12 +17,20 @@ module.exports = {
|
|||
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!');
|
||||
if(amount <= 0) return interaction.reply({ content: "<:xmark:1238963594758979736> This is not a valid number!", ephemeral: true });
|
||||
|
||||
if(!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) return interaction.reply({ content: "<:xmark:1238963594758979736> You dont have permission to use this command", ephemeral: true });
|
||||
|
||||
try {
|
||||
await interaction.channel.bulkDelete(amount);
|
||||
interaction.channel.send(`<:checkmark:1238736677942460438> Deleted ${amount} of messages!`);
|
||||
await interaction.reply({ content: `<:checkmark:1238964552482422844> Deleted ${amount} of messages!`, ephemeral: false });
|
||||
|
||||
console.log(informationStatus + `Cleared ${amount} amount of text in #${interaction.channel.name} with id of ${interaction.channel.id}`);
|
||||
|
||||
await wait(6_000);
|
||||
await interaction.deleteReply();
|
||||
} catch (error) {
|
||||
await interaction.reply({ content: "Sorry! Could not execute the clear command. Something went wrong", ephemeral: true });
|
||||
console.log(errorStatus + "Something went wrong while trying to clear messages! Debug information is below.");
|
||||
console.error(error);
|
||||
}
|
||||
|
|
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -11,7 +11,9 @@
|
|||
"dependencies": {
|
||||
"discord.js": "^14.15.2",
|
||||
"fs": "^0.0.1-security",
|
||||
"path": "^0.12.7"
|
||||
"path": "^0.12.7",
|
||||
"promises": "^0.2.5",
|
||||
"timers": "^0.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/builders": {
|
||||
|
@ -265,6 +267,16 @@
|
|||
"node": ">= 0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/promises": {
|
||||
"version": "0.2.5",
|
||||
"resolved": "https://registry.npmjs.org/promises/-/promises-0.2.5.tgz",
|
||||
"integrity": "sha512-KHTer6YK1+aD2AcLiRuE3/ilZzw1UoX8v6DuTlDdF0oc5uOZlyWA+x2JwaO0bPB+E/JiRiUQmjfuNXiWlVD2tQ=="
|
||||
},
|
||||
"node_modules/timers": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/timers/-/timers-0.1.1.tgz",
|
||||
"integrity": "sha512-pkJC8uIP/gxDHxNQUBUbjHyl6oZfT+ofn7tbaHW+CFIUjI+Q2MBbHcx1JSBQfhDaTcO9bNg328q0i7Vk5PismQ=="
|
||||
},
|
||||
"node_modules/ts-mixer": {
|
||||
"version": "6.0.4",
|
||||
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz",
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
"dependencies": {
|
||||
"discord.js": "^14.15.2",
|
||||
"fs": "^0.0.1-security",
|
||||
"path": "^0.12.7"
|
||||
"path": "^0.12.7",
|
||||
"promises": "^0.2.5",
|
||||
"timers": "^0.1.1"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue