import type { ButtonInteraction, Client } from "discord.js"; import { getTicketById } from "@/utils/queries"; import { generateTranscript } from "@/utils/transcripts"; export default { buttonExecute: async (_client: Client, interaction: ButtonInteraction) => { const [, id] = interaction.customId.split(":"); const { data: ticket, exists } = await getTicketById(null, Number(id)); if (!exists) { await interaction.reply({ content: "Ticket not found.", ephemeral: true, }); return; } const [transcriptText] = await generateTranscript(ticket); await interaction.reply({ files: [ { attachment: Buffer.from(transcriptText, "utf-8"), name: `transcript-${ticket.id}.txt`, }, ], flags: ["Ephemeral"], }); }, };