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 = /<(?a?):(?\w{0,22})\w*:(?\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 = ""; } }, };