all repos — stealth-developers @ 6c1094cd3d39e42163fcd5e1ca3a8522231057ed

bot: thank you for handling ticket button
vi did:web:vt3e.cat
Wed, 08 Jul 2026 03:08:34 +0100
commit

6c1094cd3d39e42163fcd5e1ca3a8522231057ed

parent

134e675802cf97c838c6c843e6bcb9c9f02c4fb3

1 files changed, 30 insertions(+), 4 deletions(-)

jump to
M apps/bot/src/feats/tickets/buttons.tsapps/bot/src/feats/tickets/buttons.ts

@@ -1,6 +1,6 @@

import { option } from "@purrkit/router"; import { Result } from "@sapphire/framework"; -import { type TicketWithRelations, getTicketsByUser } from "@stealth-developers/db"; +import { type TicketWithRelations, editTicket, getTicketsByUser } from "@stealth-developers/db"; import { ActionRowBuilder, ButtonBuilder,

@@ -10,7 +10,7 @@ TextDisplayBuilder,

} from "discord.js"; import { kitten } from "@/client"; -import { PublicError, errorMessage, handleError } from "@/lib"; +import { PublicError, errorMessage, getTextChannel, handleError } from "@/lib"; import { useGetTicketData } from "@/middleware"; import * as actions from "./actions";

@@ -230,11 +230,37 @@ if (result.isErr()) return errorMessage(interaction, "Failed to delete ticket channel");

}, }); -export const thankButton = kitten.button("b-thank-ticket", { +export const thankButton = useGetTicketData.button("b-thank-ticket", { options: { ticketId: option.string({ required: true }), }, - async run() {}, + async run(interaction, _, ctx) { + const { guild, ticket } = ctx; + if (!guild) return errorMessage(interaction, "Failed to find guild"); + if (!ticket) return errorMessage(interaction, "Failed to find ticket"); + + const thankedAt = ticket.thankedAt; + if (thankedAt) return errorMessage(interaction, "You already thanked for this ticket"); + + const channelRes = await Result.fromAsync(getTextChannel(guild.ticketLogChannel!)); + if (!channelRes.unwrapErr()) + return errorMessage(interaction, "Failed to find ticket log channel"); + const channel = channelRes.unwrap(); + + await editTicket(ticket.id, { + thankedAt: new Date(), + }); + + Promise.all([ + channel.send({ + content: `The reporter said thank you for handling ticket #${ticket.localId}! 💖`, + }), + interaction.reply({ + content: "A thank you has been sent! 💖", + ephemeral: true, + }), + ]).catch(() => {}); + }, }); //