const { // Clients : Client, IntentsBitField, // Embeds : EmbedBuilder, // Buttons : ActionRowBuilder, ButtonBuilder, ButtonStyle, // Modals: ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js'); const keep_alive = require('./keep_alive.js'); const client = new Client({ intents: [ IntentsBitField.Flags.Guilds, IntentsBitField.Flags.GuildMembers, IntentsBitField.Flags.GuildMessages, IntentsBitField.Flags.MessageContent ] }); client.on('ready', (r) => { console.log(`✅ ${r.user.tag} is online.`); }); const updateEmbedButtons = new ActionRowBuilder().addComponents( new ButtonBuilder() .setLabel("Suggestion") .setCustomId("suggestion-button") .setEmoji("📩") .setStyle(ButtonStyle.Success) ); client.on('interactionCreate', async (slashcmd) => { try { if (!slashcmd.isChatInputCommand()) return; switch (slashcmd.commandName) { case 'downloads': const downloadsEmbed = new EmbedBuilder() .setTitle('Downloads :') .setDescription('**Here are the list of things i made:**\n\n') .setImage('https://i.imgur.com/yrY1vI0.png') .setThumbnail(slashcmd.guild.iconURL()) .setColor(0x0099FF) .addFields({ name: 'THEssentials:', value: 'Seems like its not released yet.', inline: true }, { name: 'Minecraft Essential Utilities:', value: 'Seems like its discontinued', inline: true }); await slashcmd.reply({ embeds: [downloadsEmbed] }); break; case 'addon-changelog': const addon = slashcmd.options.getString('addon-name'); const addondescription = slashcmd.options.getString('changelogs').replaceAll("&l", "\n").trim().split("|"); const version = slashcmd.options.getString('version'); const image = slashcmd.options.getString('image') || 'https://i.imgur.com/Yu7Qutv.jpg'; if (!slashcmd.member.roles.cache.some(mod => mod.name === "Moderator")) return slashcmd.reply({ content: "You don't have enough permissions to use this command.", ephemeral: true }); if (addondescription.length < 2) return slashcmd.reply({ content: "Invalid changelog format. It should have at least two sections separated by '|'.", ephemeral: true }); const updatesEmbed = new EmbedBuilder() .setTitle(addon) .setDescription(`**${addondescription[0]}**:\n\n${addondescription[1]}`) .setColor(0xD2042D) .setImage(image) .setTimestamp() .setFooter({ text: `Version: ${version}`, iconURL: slashcmd.user.avatarURL() }); await slashcmd.reply({ content: '<@&1143463019888787476>', embeds: [updatesEmbed], components: [updateEmbedButtons] }); break; default: await slashcmd.reply({ content: `Command **${slashcmd.commandName}** does not exist.`, ephemeral: true }); break; } } catch (err) { console.log('Catched error: ', err); } }); client.on("interactionCreate", async (buttonInteraction) => { if (!buttonInteraction.isButton()) return; switch (buttonInteraction.customId) { case 'suggestion-button': const suggestionModal = new ModalBuilder() .setCustomId("suggestion-modal") .setTitle("Suggestions"); const inputSuggestion = new TextInputBuilder() .setCustomId("suggestion-input") .setLabel("Suggestion :") .setPlaceholder("Put your suggestion here..") .setMinLength(10) .setMaxLength(1800) .setStyle(TextInputStyle.); const inputSuggestionRow = new ActionRowBuilder().addComponents(inputSuggestion); suggestionModal.addComponents(inputSuggestionRow); await buttonInteraction.showModal(suggestionModal); break; } }); client.on("interactionCreate", async (interaction) => { if (!interaction.isModalSubmit()) return; const modalSubmmisionsChannel = client.channels.cache.get('1147403033496526888'); const suggestion = interaction.fields.getTextInputValue('inputSuggestion'); console.log(`Channel: ${modalSubmmisionsChannel} | Suggestion: ${suggestion}`); await modalSubmmisionsChannel.send(`Submission: ${suggestion}`); }); client.login(process.env['TOKEN']);