src/interactions/buttons/transcript-btn.ts (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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"],
});
},
};
|