const { ButtonInteraction, EmbedBuilder, ModalSubmitInteraction, codeBlock, userMention, ActionRowBuilder, ButtonBuilder, ButtonStyle, WebhookClient, Attachment } = require('discord.js'); const ExtendedClient = require('../../class/ExtendedClient'); const config = require('../../config'); const { createTranscript } = require('discord-html-transcripts'); const { time } = require('../../functions'); module.exports = { customId: 'Tmoda', /** * * @param {ExtendedClient} client * @param {ModalSubmitInteraction} interaction */ run: async (client, interaction) => { const openTime = interaction.channel.createdAt; const closedBy = interaction.member.id; const openedBy = interaction.channel.topic.split('-')[1]; const mess = await interaction.channel.messages.fetch({ limit: 1 }); const me = mess.first(); const Ticket_type = me.embeds[0].fields[1].value; await interaction.reply({ embeds: [ new EmbedBuilder() .setDescription(`${config.emoji.ds_loading} Sto Chiudendo il tuo ticket`) .setColor('Yellow'), ], }); const file = await createTranscript(interaction.channel, { limit: -1, saveImages: true, poweredBy: false, returnType: 'attachment', //returnBuffer: false, filename: `transcript.html` }); const channe = interaction.guild.channels.cache.get(config.canali.ticketTrancripts); var msg = await channe.send({ content: '.', files: [file] }); var msgUrl = `https://mahto.id/chat-exporter?url=${msg.attachments.first()?.url}`; await msg.delete().catch(err => {}); const webhook = new WebhookClient({ url: process.env.WEBHOOK_TRANCRIPTS }); await webhook.send({ username: 'Ticket Transcripts - Emeral RP', //files: [file], avatarURL: config.loghi.giallo, embeds: [ new EmbedBuilder() .setTitle('๐ŸŽซ TICKET CHIUSO') .setColor('Yellow') .setThumbnail(config.loghi.giallo) .setFooter({ text: 'Ticket Transcript - Emeral RP', iconURL: config.loghi.giallo }) .setTimestamp() .addFields( { name: config.emoji.tipoTicket + ' Tipo Ticket', value: Ticket_type, }, { name: config.emoji.membro_ds + ' Aperto Da:', value: '> ' + userMention(openedBy) }, { name: config.emoji.ticket_closedBy + ' Chiuso Da', value: '> ' + userMention(closedBy), }, { name: config.emoji.ticketOpen + ' Data Apertura', value: '> ' + time(openTime, 'f') }, { name: config.emoji.reason + ' Motivo Chiusura', value: `> \`${interaction.fields.getTextInputValue('motivoo')}\`` }, ), ], components: [ new ActionRowBuilder().addComponents( new ButtonBuilder() .setLabel('Vedi il Ticket Trancript') .setStyle(ButtonStyle.Link) .setEmoji(config.emoji.trancript_cartella) .setURL(msgUrl) ) ], }); const member = await interaction.guild.members.fetch(openedBy); await member.send({ embeds: [ new EmbedBuilder() .setTitle('๐ŸŽซ TICKET CHIUSO [server principale]') .setColor('Yellow') .setThumbnail(config.loghi.giallo) .setDescription(`Il tuo ticket ${Ticket_type.slice(2)} sul server principale รจ stato chiuso`), ], components: [ new ActionRowBuilder().addComponents( new ButtonBuilder() .setURL('https://discord.com/channels/1150385283255259256/1162365563268501594/1171835323152605184') .setStyle(ButtonStyle.Link) .setLabel('Recensisci lo Staff') .setEmoji('๐Ÿ”ฐ') ) ] }).catch( err => {}); await interaction.channel.delete('ticket chiuso'); } };