feature: emote adding, listing and removing

This commit is contained in:
skkeye
2023-11-02 22:54:08 -04:00
commit ecb0d624ab
11 changed files with 1643 additions and 0 deletions

29
commands/emotes/rm.js Normal file
View File

@@ -0,0 +1,29 @@
const { SlashCommandBuilder } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("rm")
.setDescription("Removes emotes from the server.")
.addStringOption(option =>
option.setName("emotes")
.setDescription("Emotes to remove.")
.setRequired(true)),
async execute(interaction) {
await interaction.reply("Removing emotes...");
// find every emote in the message and remove them
let emoteList = interaction.options.getString("emotes");
let emoteIdRegex = /<(?<animated>a?):(?<name>\w{0,22})\w*:(?<id>\d+)>/gm;
let replyMessage = "";
for (const match of emoteList.matchAll(emoteIdRegex)) {
let emote = interaction.guild.emojis.cache.find(emoji => emoji.id === match.groups.id);
if (emote) {
await emote.delete();
replyMessage += `Removed ${match[0]}!\n`;
} else {
replyMessage += `Could not find ${match[0]}!\n`;
}
interaction.editReply(replyMessage);
replyMessage = "";
}
},
};