bot: show comments in log channel; on button press
vi did:web:vt3e.cat
Sat, 27 Jun 2026 02:41:14 +0100
2 files changed,
52 insertions(+),
3 deletions(-)
M
apps/bot/src/feats/tickets/actions.ts
→
apps/bot/src/feats/tickets/actions.ts
@@ -257,6 +257,39 @@ container.addActionRowComponents(actionRow);
return container; } +export function getCommentContainer(ticketId: number, comments: TicketWithRelations["comments"]) { + const formatTime = (date: Date) => `<t:${Math.floor(date.getTime() / 1000)}>`; + + const container = new ContainerBuilder(); + container.addTextDisplayComponents( + new TextDisplayBuilder().setContent(`## Comments on #${String(ticketId).padStart(4, "0")}`), + ); + + if (!comments || comments.length === 0) { + container.addTextDisplayComponents(new TextDisplayBuilder().setContent("No comments found")); + return container; + } + + const recentComments = comments.slice(-10); + + recentComments.forEach((comment) => { + const authorMention = comment.actor?.discordId + ? `<@${comment.actor.discordId}>` + : "Unknown User"; + + const quotedContent = (comment.content || "") + .split("\n") + .map((line) => `> ${line}`) + .join("\n"); + + const commentString = `**${authorMention}** (${formatTime(comment.createdAt)})\n${quotedContent}`; + + container.addTextDisplayComponents(new TextDisplayBuilder().setContent(commentString)); + }); + + return container; +} + /** * * @param user@@ -348,10 +381,13 @@ content: `No log channel was found, a notification was not sent.`,
}); } else { const container = getTicketContainer(result, false); + const commentContainer = getCommentContainer(result.localId, result.comments); + const message = await Result.fromAsync( messageChannel(logChannel, { - components: [container], + components: [container, commentContainer], flags: ["SuppressNotifications", "IsComponentsV2"], + allowedMentions: { parse: [] }, }), );