const msg = await interaction.editReply({ embeds: [ new EmbedBuilder() .setColor("2f3136") .setDescription( "Are you sure you want to close this ticket?\n> Please save transcripts for majority of tickets unless it's not neccessary" ) .setTimestamp(), ], components: [ new ActionRowBuilder().addComponents( new ButtonBuilder() .setCustomId("delete") .setLabel("Close") .setStyle(ButtonStyle.Primary), new ButtonBuilder() .setCustomId("no-trans") .setStyle(ButtonStyle.Secondary) .setLabel('No Transcript') ), ], }); const collector = msg.createMessageComponentCollector({ time: 20000, }); collector.on("collect", async (btn) => { await btn.update({ components: [] }); if(btn.customId == 'no-trans') { await interaction.channel.messages .edit(data.managemsg, { embeds: [EmbedBuilder.from(interaction.message.embeds[1] || interaction.message.embeds[0])], components: [], }) .catch(() => btn.followUp({ content: "Something went wrong while editing the manage message", ephemeral: true })); await btn.channel.send({ content: 'Closing channel now', }) await support.updateOne( { userId: interaction.channel.topic, type }, { open: false, closeDate: new Date(), closedBy: btn.user.id } ); setTimeout(async () => { await btn.channel.delete().catch(() => {}) }, 10000); } if (btn.customId === "delete") { const embed = new EmbedBuilder() .setDescription( `Preparing to close channel...\nTranscript: ` ) .setTimestamp() .setColor('#2b2d31'); let msg = await btn.channel.send({ embeds: [ embed ] }) await interaction.channel.messages .edit(data.managemsg, { components: [], }) .catch(() => btn.followUp({ content: "Something went wrong while editing the manage message", })); let transcript = await generateTranscript(btn.channel.guild, btn.channel, data.transcriptId) await msg.edit({ embeds: [ EmbedBuilder.from(msg.embeds[0]) .setDescription(msg.embeds[0].description.replace('', transcript ? '<:yes_tick:1103666879492530256>' : '<:no:1103667033318629556>')+ '\nDMing user transcript: ') ] }) await web.send({ embeds: [ new EmbedBuilder() .setTitle("📁 Transcript created") .setDescription(`New transcript for #${btn.channel.name}`) .addFields([ { name: "Online link", value: `[Click here](https://www.gwapes.com/thearcade/transcripts/${data.transcriptId}.html)` } ]) .setTimestamp() .setColor('Aqua') ], components: [ new ActionRowBuilder().addComponents( new ButtonBuilder() .setStyle(ButtonStyle.Link) .setLabel('Link') .setURL(`https://www.gwapes.com/thearcade/transcripts/${data.transcriptId}.html`) ) ], files: [transcript] }) .catch((e) => { console.log(e, `Transcript failed to send to web, ${type}, ${interaction.channel.topic}`); btn.followUp({ content: "Something went wrong while sending the transcript", ephemeral: true }); }); const userData = await getUser(interaction.channel.topic, interaction.guildId) let sent; if (!userData || userData.DMTranscript !== false) { sent = await client.users.send(interaction.channel.topic, { embeds: [ new EmbedBuilder() .setTitle(`Ticket closed`) .setDescription(`Here is your ticket for type: ${config[type]?.DMMsgText}`) .setColor('bebebe') .addFields([ { name: "Online link", value: `[Click here](https://www.gwapes.com/thearcade/transcripts/${data.transcriptId}.html)` } ]) .setTimestamp() .setFooter( { text: "use /user settings edit to not receive dms", iconURL: interaction.guild.iconURL() } ) ], components: [ new ActionRowBuilder().addComponents( new ButtonBuilder() .setStyle(ButtonStyle.Link) .setLabel('Link') .setURL(`https://www.gwapes.com/thearcade/transcripts/${data.transcriptId}.html`) ) ], }).catch(() => { btn.followUp({ content: 'Couldnt dm user their transcript', ephemeral: true }) return null; }); } await msg.edit({ embeds: [ EmbedBuilder.from(msg.embeds[0]) .setDescription(msg.embeds[0].description.replace('', sent ? '<:yes_tick:1103666879492530256>' : '<:no:1103667033318629556>') + '\n\nDeleting channel in 10 seconds') ] }); await support.updateOne( { userId: interaction.channel.topic, type }, { open: false, closeDate: new Date(), closedBy: btn.user.id } ); setTimeout(async () => { await btn.channel.delete().catch(() => {}) }, 10000); } }); collector.on("end", async (collected, reason) => { if (reason === "time") { await interaction.editReply({ embeds: [ EmbedBuilder.from( interaction.message.embeds[0] ).setDescription("You ran out of time"), ], components: [], }); } });