all repos — stealth-developers @ e24ca93b2bb2cef8fa9c346db7bb7f07bada0973

bot: show comments in log channel; on button press
vi did:web:vt3e.cat
Sat, 27 Jun 2026 02:41:14 +0100
commit

e24ca93b2bb2cef8fa9c346db7bb7f07bada0973

parent

3cce197b87dde34e731a376deec555215cbd0bb1

2 files changed, 52 insertions(+), 3 deletions(-)

jump to
M apps/bot/src/feats/tickets/actions.tsapps/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: [] }, }), );
M apps/bot/src/feats/tickets/buttons.tsapps/bot/src/feats/tickets/buttons.ts

@@ -134,11 +134,24 @@ await interaction.showModal(TicketModalPresets.comment(ticket.id));

}, }); -export const viewCommentsButton = kitten.button("b-comment-ticket", { +export const viewCommentsButton = useGetTicketData.button("b-comment-ticket", { options: { ticketId: option.string({ required: true }), }, - async run() {}, + async run(interaction, _, { ticket, actor }) { + if (!ticket || !actor) return errorMessage(interaction, "Failed to find ticket"); + if (!actor.moderator) + return errorMessage(interaction, "You must be a moderator to use this command"); + + const { comments } = ticket; + const container = actions.getCommentContainer(ticket.localId, comments); + + await interaction.reply({ + components: [container], + flags: ["Ephemeral", "IsComponentsV2"], + allowedMentions: { parse: [] }, + }); + }, }); //