const { ButtonInteraction, EmbedBuilder, StringSelectMenuInteraction, ChannelType, PermissionFlagsBits, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ButtonBuilder, ButtonStyle, } = require("discord.js"); module.exports = { name: "interactionCreate", /** * * @param {StringSelectMenuInteraction} interaction * */ async execute(interaction) { if (!interaction.isStringSelectMenu()) return; const modal = new ModalBuilder({ customId: "ticketModal", title: `Criar ticket - ${interaction.guild.name}`, }); const ticketTitle = new TextInputBuilder({ customId: "ticketTitle", label: "Título do Ticket:", style: TextInputStyle.Paragraph, }); const details = new TextInputBuilder({ customId: "details", label: "Conta-nos melhor o assunto do teu ticket:", style: TextInputStyle.Paragraph, }); const firstRow = new ActionRowBuilder().addComponents(ticketTitle); const secondRow = new ActionRowBuilder().addComponents(details); modal.addComponents(firstRow, secondRow); if (interaction.guild.id === "744706236192391578") { if (interaction.value[0] === "doubt") { let name = `doubt-${interaction.user.id}`; let c = interaction.guild.channels.cache.find((c) => c.name === name); if (c) { interaction.reply({ content: `❌ Já tens um ticket aberto: <#${c}>`, ephemeral: true, }); } else { await interaction.showModal(modal); const filter = (interaction) => interaction.customId === "ticketModal"; interaction .awaitModalSubmit({ filter, time: 60_000 }) .then((modalInteraction) => { const Title = modalInteraction.fields.getTextInputValue("ticketTitle"); const Paragraph = modalInteraction.fields.getTextInputValue("details"); interaction.guild.channels .create({ name: name, type: ChannelType.GuildText, permissionOverwrites: [ { id: interaction.guild.id, deny: [PermissionFlagsBits.ViewChannel], }, { id: interaction.user.id, allow: [ PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, PermissionFlagsBits.AttachFiles, PermissionFlagsBits.EmbedLinks, PermissionFlagsBits.AddReactions, ], }, ], }) .then((ch) => { interaction.reply({ content: `✅ Ticket criado com sucesso: <#${ch}>`, ephemeral: true, }); let embed = new EmbedBuilder() .setColor("White") .setDescription( `Um Novo Ticket Foi Aberto <@744717566127243316>\nInformações:` ) .addFields( { name: "Membro:", value: interaction.user, inline: true, }, { name: "Categoria:", value: "❓", inline: true, }, { name: "Título:", value: Title, inline: false, }, { name: "Detalhes:", value: Paragraph, inline: false, } ); const buttons = new ActionRowBuilder().addComponents( new ButtonBuilder() .setCustomId("closeTicket") .setStyle(ButtonStyle.Danger) .setEmoji("🔒") ); return ch .send({ embeds: [embed], components: [buttons] }) .then((m) => m.pin()); }); }); } } } }, };