const { ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, EmbedBuilder } = require('discord.js'); module.exports = async (client) => { client.on('interactionCreate', async (interaction) => { if (interaction.isSelectMenu()) { const { member, channel } = interaction; if(interaction.values[0] === "bugModal"){ const modal = new ModalBuilder() .setCustomId('myModal') .setTitle('Report a Bug'); const title = new TextInputBuilder() .setCustomId('title') .setLabel("Title") .setStyle(TextInputStyle.Short) .setRequired(true) .setMaxLength(50); const bugtextx = new TextInputBuilder() .setCustomId('bugtextx') .setLabel("Describe the bug.") .setStyle(TextInputStyle.Paragraph) .setRequired(true) .setMaxLength(3000); const screen = new TextInputBuilder() .setCustomId('screen') .setLabel("If you have an image") .setStyle(TextInputStyle.Short) .setRequired(false) .setMaxLength(88); const firstActionRow = new ActionRowBuilder().addComponents([title]); const secondActionRow = new ActionRowBuilder().addComponents([bugtextx]); const thirdActionRow = new ActionRowBuilder().addComponents([screen]); modal.addComponents([firstActionRow, secondActionRow, thirdActionRow]); await interaction.showModal(modal); if (!interaction.isModalSubmit()) return; } else { const bugLOG = member.guild.channels.cache.find(ch => ch.id === '964183272202592306'); const title = interaction.fields.getTextInputValue('title'); const bugtextx = interaction.fields.getTextInputValue('bugtextx'); const screen = interaction.fields.getTextInputValue('screen'); const thread = await channel.threads.create({ name: `${title}`, autoArchiveDuration: 10080, }); const lastMessages = await channel.messages.fetch({ limit: 10 }); const systemMessage = lastMessages.reverse().find(message => message.system) if (systemMessage) await systemMessage.delete(); let thredEMBED = new EmbedBuilder() .setAuthor({ name: `${interaction.user.tag} | (${interaction.user.id})` }) .setTitle(`${title}`) .setDescription(`${bugtextx}`) .setImage(screen.includes("http://") || screen.includes("https://") ? `${screen}` : null) .setColor(client.config.color) await thread.send({ embeds: [thredEMBED] }) await thread.members.add(interaction.user.id) await thread.permissionsFor(interaction.user.id) let embed = new EmbedBuilder() .setAuthor({ name: `${interaction.user.tag} | (${interaction.user.id})` }) .setTitle(`${title}`) .setDescription(`${bugtextx}\n\n[View thread](https://discord.com/channels/934213686468423780/${thread.id})`) .setImage(screen.includes("http://") || screen.includes("https://") ? `${screen}` : null) .setColor(client.config.color) bugLOG.send({ embeds: [embed] }); await bugLOG.send("<@&936782688495497226> || <@717416034478456925>").then(msg => { msg.delete().catch(() => { }) }) } } await interaction.reply({ content: `Bug report received!`, ephemeral: true }); }); }