all repos — stealth-developers @ 2080a689c216d781e762adf4c86617edf7311c7e

feat: view transcript button
vi v@vt3e.cat
Wed, 04 Mar 2026 23:37:05 +0000
commit

2080a689c216d781e762adf4c86617edf7311c7e

parent

3c41df9e8adbe65a754033f4ddb152b5eeeef4ca

A src/interactions/buttons/transcript-btn.ts

@@ -0,0 +1,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"], + }); + }, +};
M src/interactions/commands/tickets/_shared.tssrc/interactions/commands/tickets/_shared.ts

@@ -2,7 +2,10 @@ import type { Attachment, Ticket } from "@/database";

import { getPublicUrl } from "@/utils/s3"; import { generateTranscript } from "@/utils/transcripts"; import { + ActionRowBuilder, AttachmentBuilder, + ButtonBuilder, + ButtonStyle, ContainerBuilder, FileBuilder, LabelBuilder,

@@ -72,7 +75,6 @@

export function constructTicketContainer( ticket: Ticket, attachmentsString: string, - file: AttachmentBuilder, _context: "closed" | "view" = "closed", isPublic = true, ) {

@@ -93,6 +95,13 @@ reason

? `### ${title} Reason\n${reason}` : `### ${title} Reason\n-# No ${title.toLowerCase()} reason provided.`; + const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents( + new ButtonBuilder() + .setCustomId(`transcript-btn:${ticket.id}`) + .setLabel("View Transcript") + .setStyle(ButtonStyle.Primary), + ); + const container = new ContainerBuilder() .addTextDisplayComponents( new TextDisplayBuilder().setContent(

@@ -127,7 +136,7 @@ .filter(Boolean)

.join("\n"), ), ) - .addFileComponents(new FileBuilder().setURL(`attachment://${file.name}`)); + .addActionRowComponents(buttons); return container; }

@@ -153,7 +162,6 @@ return {

container: constructTicketContainer( ticket, attachmentsString, - file, context, isPublic, ),
M src/interactions/commands/tickets/actions.tssrc/interactions/commands/tickets/actions.ts

@@ -282,7 +282,6 @@

await transcriptChannel.send({ components: [staffMessage.container], flags: ["IsComponentsV2"], - files: staffMessage.files, allowedMentions: { users: [], },