const selectCollector = interaction.channel.createMessageComponentCollector({ componentType: ComponentType.StringSelect }); selectCollector.on('collect', async (i) => { const ticketType = i.values[0]; if (ticketType) { // Handle ticket creation based on the selected ticket type if (i.customId === 'supportselection') { // Create the support modal const supportModal = new ModalBuilder() .setCustomId('supportmodal') .setTitle('Support Ticket Form'); // support Forms: const supportFirst = new TextInputBuilder() .setCustomId('support_first') .setLabel("🔹 Your In-game name?") .setStyle(TextInputStyle.Short) .setRequired(true); const supportSecond = new TextInputBuilder() .setCustomId('support_second') .setLabel("🔹 What are you looking for in this ticket?") .setStyle(TextInputStyle.Short) .setRequired(true); const supportThird = new TextInputBuilder() .setCustomId('support_second') .setLabel("🔹 The title of the report?") .setStyle(TextInputStyle.Short) .setRequired(true); const supportForth = new TextInputBuilder() .setCustomId('support_second') .setLabel("🔹 Please describe your question here 😉") .setStyle(TextInputStyle.Paragraph) .setRequired(true); // An action row only holds one text input, // so you need one action row per text input. const supportFirstActionRow = new ActionRowBuilder().addComponents(supportFirst); const supportSecondActionRow = new ActionRowBuilder().addComponents(supportSecond); const supportThirdActionRow = new ActionRowBuilder().addComponents(supportThird); const supportForthActionRow = new ActionRowBuilder().addComponents(supportForth); // Add inputs to the modal supportModal.addComponents(supportFirstActionRow, supportSecondActionRow, supportThirdActionRow, supportForthActionRow); // Show the modal to the user await i.showModal(supportModal); } else if (i.customId === 'billingselection') { // Create the billing modal const billingModal = new ModalBuilder() .setCustomId('billingmodal') .setTitle('Billing Ticket Form'); // Billing Forms: const billingFirst = new TextInputBuilder() .setCustomId('billing_first') .setLabel("🔸 Your In-game name?") .setStyle(TextInputStyle.Short) .setRequired(true); const billingSecond = new TextInputBuilder() .setCustomId('billing_second') .setLabel("🔸 Your e-mail for purchasing?") .setStyle(TextInputStyle.Short) .setRequired(true); const billingThird = new TextInputBuilder() .setCustomId('billing_second') .setLabel("🔸 Your prefered payment gateway?") .setStyle(TextInputStyle.Short) .setRequired(true); const billingForth = new TextInputBuilder() .setCustomId('billing_second') .setLabel("🔸 What you would like to purchase?") .setStyle(TextInputStyle.Short) .setRequired(true); const billingFifth = new TextInputBuilder() .setCustomId('billing_second') .setLabel("🔸 Please describe your question here 😉") .setStyle(TextInputStyle.Paragraph) .setRequired(true); // An action row only holds one text input, // so you need one action row per text input. const billingFirstActionRow = new ActionRowBuilder().addComponents(billingFirst); const billingSecondActionRow = new ActionRowBuilder().addComponents(billingSecond); const billingThirdActionRow = new ActionRowBuilder().addComponents(billingThird); const billingForthActionRow = new ActionRowBuilder().addComponents(billingForth); const billingFifthActionRow = new ActionRowBuilder().addComponents(billingFifth); // Add inputs to the modal billingModal.addComponents(billingFirstActionRow, billingSecondActionRow, billingThirdActionRow, billingForthActionRow, billingFifthActionRow); // Show the modal to the user await i.showModal(billingModal); }; if (!i.isModalSubmit()) { return; console.log(i); } else if (supportModal.isModalSubmit()) { // After submit the modal -------------------------------------------------------- const ticketName = `Support-${i.user.id}`; const ticketroom = await ticketChannel.threads.create({ name: ticketName, type: ChannelType.PrivateThread }); console.log(`! New support ticket thread: ${ticketroom.name}`); // Send ticket Created Embed to Panel, acknowledge user the ticket successfully created. const supportCreatedEmbed = new EmbedBuilder() .setColor('#499D6C') .setDescription(`**💌 | Ticket Created**\nOpened a new ticket: ${ticketroom}`) .setFooter({ text: bot.config.embed.footer, iconURL: bot.config.embed.serverIcon }) .setTimestamp(); await panelMessage.reply({ embeds: [supportCreatedEmbed], ephemeral: true }); // Then send the ticket Welcome Embed to the ticket room const supportWelcomeEmbed = new EmbedBuilder() .setColor('#499D6C') .setDescription(`## **💌 TICKET CREATED - SUPPORT**`) .addFields( { name: ' ', value: `Hello @${i.user.id}` + `Thank you for contacting support.` + `Please describe your issue and support team will response as soon as possible!` }, { name: ' ', value: `\n\n` + `[**ᴡɪᴋɪ**](https://wiki.skyhikermc.com/) **·** [**ꜱᴛᴏʀᴇ**](http://store.skyhikermc.com/) **·** ` + `[**ʀᴜʟᴇꜱ**](https://wiki.skyhikermc.com/rules) **·** [**ꜰᴀᴄᴇʙᴏᴏᴋ**](https://www.facebook.com/SkyHikerMC/) **·** ` + `[**ᴅɪꜱᴄᴏʀᴅ**](https://discord.skyhikermc.com/) ` } ) .setImage('https://s10.gifyu.com/images/S4VYM.gif') .setFooter({ text: bot.config.embed.footer, iconURL: bot.config.embed.serverIcon }) .setTimestamp(); await ticketroom.send({ embeds: [supportWelcomeEmbed], components: [ticketActionRow] }); // Send the user's filled form to the ticket room const userFormData = new EmbedBuilder() .setTitle('User Form Data') .setDescription('Form data goes here') .setFooter({ text: bot.config.embed.footer, iconURL: bot.config.embed.serverIcon }) .setTimestamp(); await ticketroom.send({ embeds: [userFormData] }); } else if (billingModal.isModalSubmit()) { // if Billing Modal Submitted const ticketName = `Billing-${i.user.id}`; const ticketroom = await ticketChannel.threads.create({ name: ticketName, type: ChannelType.PrivateThread }); console.log(`! New billing ticket thread: ${ticketroom.name}`); // Send ticket Created Embed to Panel, acknowledge user the ticket successfully created. const billingCreatedEmbed = new EmbedBuilder() .setColor('#4E5DBC') .setDescription(`**💌 | Ticket Created**\nOpened a new ticket: ${ticketroom}`) .setFooter({ text: bot.config.embed.footer, iconURL: bot.config.embed.serverIcon }) .setTimestamp(); await panelMessage.reply({ embeds: [billingCreatedEmbed], ephemeral: true }); // Then send the ticket Welcome Embed to the ticket room const billingWelcomeEmbed = new EmbedBuilder() .setColor('#4E5DBC') .setDescription(`## **💳 TICKET CREATED - BILLING**`) .addFields( { name: ' ', value: `Hello @${i.user.id}` + `Thank you for contacting support.` + `Please describe your issue and support team will response as soon as possible!` }, { name: ' ', value: `\n\n` + `[**ᴡɪᴋɪ**](https://wiki.skyhikermc.com/) **·** [**ꜱᴛᴏʀᴇ**](http://store.skyhikermc.com/) **·** ` + `[**ʀᴜʟᴇꜱ**](https://wiki.skyhikermc.com/rules) **·** [**ꜰᴀᴄᴇʙᴏᴏᴋ**](https://www.facebook.com/SkyHikerMC/) **·** ` + `[**ᴅɪꜱᴄᴏʀᴅ**](https://discord.skyhikermc.com/) ` } ) .setImage('https://s10.gifyu.com/images/S4VYz.gif') .setFooter({ text: bot.config.embed.footer, iconURL: bot.config.embed.serverIcon }) .setTimestamp(); await ticketroom.send({ embeds: [billingWelcomeEmbed], components: [ticketActionRow] }); // Send the user's filled form to the ticket room const userFormData = new EmbedBuilder() .setTitle('User Form Data') .setDescription('Form data goes here') .setFooter({ text: bot.config.embed.footer, iconURL: bot.config.embed.serverIcon }) .setTimestamp(); await ticketroom.send({ embeds: [userFormData] }); } }; }); selectCollector.on('end', collected => { console.log(`Collected ${collected.size} items`); }); } catch (error) { console.error('Ticket error occurred:', error); } }