M
src/interactions/buttons/tickets/ticket.ts
→
src/interactions/buttons/tickets/ticket.ts
@@ -311,6 +311,10 @@ if (action === "list") {
await handleList(client, interaction);
return;
}
+ if (action === "export") {
+ await handleExport(client, interaction);
+ return;
+ }
const { data: guild } = await getGuild(interaction.guildId);
const { data: ticket } = await getTicket(
@@ -997,6 +1001,35 @@ await interaction.editReply({
components: [container],
files: files,
flags: ["IsComponentsV2"],
+ });
+}
+
+async function handleExport(
+ _client: Client,
+ interaction: ChatInputCommandInteraction,
+) {
+ const _tickets = await db
+ .select()
+ .from(tickets)
+ .where(eq(tickets.authorId, interaction.user.id));
+
+ const transcripts = await Promise.all(
+ _tickets.map(async (ticket) => {
+ const [transcriptText] = await generateTranscript(ticket);
+ return transcriptText;
+ }),
+ );
+
+ const combined = transcripts.join("\n\n\n\n");
+ await interaction.reply({
+ content: "Here is your exported ticket data:",
+ files: [
+ {
+ attachment: Buffer.from(combined, "utf-8"),
+ name: `tickets-export-${interaction.user.id}.txt`,
+ },
+ ],
+ flags: ["Ephemeral"],
});
}