const { SlashCommandBuilder, ModalBuilder, LabelBuilder, TextInputBuilder, FileUploadBuilder, TextInputStyle, StringSelectMenuBuilder, EmbedBuilder, MessageFlags, StringSelectMenuOptionBuilder, } = require("discord.js"); const { getBlacklist } = require("../../utils/blacklistManager"); // config const LOG_CHANNEL_ID = "1464396687492776118"; //todo const COOLDOWN_TIME = 5 * 60 * 1000; // big list of no-no words const BAD_WORDS = [ "mee6", "kafaf", "fuck", "shit", "bitch", "asshole", "dick", "pussy", "bastard", "cunt", "whore", "slut", "faggot", "nigger", "nigga", "retard", "idiot", "stupid", "cock", "wanker", "twat", "motherfucker", "dumbass", "douche", "scum", "prick", "bullshit", "bollocks", "arse", "blowjob", "cum", "anal", "sex", "rape", "molest", "pedo", "porn", "xxx", "hentai", "kill yourself", "kys", "suicide", "hitler", "nazi", "terrorist", ]; const cooldowns = new Map(); module.exports = { data: new SlashCommandBuilder() .setName("suggestion") .setDescription("Submit a suggestion or report a bug to the developers."), async execute(interaction, client) { const userId = interaction.user.id; const currentBlacklist = getBlacklist(); // if (currentBlacklist.includes(userId)) { return interaction.reply({ content: "โ›” **Access Denied:** You have been blacklisted from using this system.", flags: MessageFlags.Ephemeral, }); } /* // 2. ACCOUNT AGE CHECK (7 Days) const minAccountAge = 1000 * 60 * 60 * 24 * 7; if (Date.now() - interaction.user.createdTimestamp < minAccountAge) { return interaction.reply({ content: "๐Ÿ›ก๏ธ **Security Alert:** Your account is too new. Anti-spam protection requires an account age of at least 7 days.", flags: MessageFlags.Ephemeral, }); } */ /* // 3. COOLDOWN CHECK if (cooldowns.has(userId)) { const expiration = cooldowns.get(userId) + COOLDOWN_TIME; if (Date.now() < expiration) { const timeLeft = Math.round((expiration - Date.now()) / 1000); return interaction.reply({ content: `โณ **Cooldown:** Please wait **${timeLeft} seconds** before submitting another suggestion.`, flags: MessageFlags.Ephemeral, }); } } */ // const modal = new ModalBuilder() .setCustomId("suggestion_modal") .setTitle("Suggestion / Bug Report"); // const textLabel = new LabelBuilder() .setLabel("Details") .setTextInputComponent( new TextInputBuilder() .setCustomId("suggestion_text") .setPlaceholder("Please describe your suggestion or bug in detail...") .setStyle(TextInputStyle.Paragraph) .setMinLength(20) .setMaxLength(1000) .setRequired(true), ); // const fileLabel = new LabelBuilder() .setLabel("Attachment (Optional)") .setFileUploadComponent( new FileUploadBuilder() .setCustomId("suggestion_file") .setRequired(false), ); // cat const categoryLabel = new LabelBuilder() .setLabel("โš™๏ธ Choose a category") .setDescription("Are you suggesting or reporting?") .setStringSelectMenuComponent( new StringSelectMenuBuilder() .setCustomId("suggestion_category") .setPlaceholder("Choose one...") .setRequired(true) .addOptions( new StringSelectMenuOptionBuilder() .setLabel("๐Ÿงพ Suggest") .setValue("suggest") .setDescription("Yes, I will suggest something..."), new StringSelectMenuOptionBuilder() .setLabel("๐Ÿ“Œ Report") .setValue("report") .setDescription("Yes, I will report something..."), ), ); modal.addLabelComponents(categoryLabel, textLabel, fileLabel); await interaction.showModal(modal); // try { const modalInteraction = await interaction.awaitModalSubmit({ filter: (i) => i.customId === "suggestion_modal" && i.user.id === userId, time: 300000, }); const text = modalInteraction.fields.getTextInputValue("suggestion_text"); const file = modalInteraction.fields .getUploadedFiles("suggestion_file") .first(); const category = modalInteraction.fields.getStringSelectValues( "suggestion_category", ); // profanity const hasProfanity = BAD_WORDS.some((word) => new RegExp(`\\b${word}\\b`, "i").test(text), ); if (hasProfanity) { return modalInteraction.reply({ content: "โš ๏ธ **Rejected:** Your suggestion contains inappropriate language. Please keep it professional.", flags: MessageFlags.Ephemeral, }); } cooldowns.set(userId, Date.now()); // logging const logChannel = client.channels.cache.get(LOG_CHANNEL_ID); if (logChannel) { const embed = new EmbedBuilder() .setColor("Blue") .setAuthor({ name: modalInteraction.user.tag, iconURL: modalInteraction.user.displayAvatarURL(), }) .setTitle(`๐Ÿ“ New ${category}`) .setDescription(text) .addFields( { name: "User ID", value: userId, inline: true }, { name: "Server ID", value: `<#${interaction.guild.id}>`, inline: true, }, { name: "Category", value: category, inline: true, }, ) .setTimestamp(); if (file) { embed.setImage(file.url); embed.setFooter({ text: `๐Ÿ“Ž Attachment: ${file.name}` }); } await logChannel.send({ embeds: [embed] }); } // await modalInteraction.reply({ content: "โœ… **Success:** Your suggestion has been sent to the developers. Thank you!", flags: MessageFlags.Ephemeral, }); } catch (err) { if (err.code !== "InteractionCollectorError") { client.logger.error("Suggestion Error:", err); } } }, };