feat(tickets): send thank you message
vi v@vt3e.cat
Sun, 01 Mar 2026 16:53:17 +0000
2 files changed,
77 insertions(+),
2 deletions(-)
M
src/interactions/commands/tickets/actions.ts
→
src/interactions/commands/tickets/actions.ts
@@ -2,7 +2,12 @@ import { type Guild, type Ticket, db, tickets } from "@/database";
import { formatMessage } from "@/utils/formatting"; import { loggers } from "@/utils/logging"; import { hasManagerPermissions } from "@/utils/permissions"; -import { getGuild, getManagerRoleIds, getTicket } from "@/utils/queries"; +import { + getGuild, + getManagerRoleIds, + getTicket, + getTicketById, +} from "@/utils/queries"; import { generateTranscript } from "@/utils/transcripts"; import { ActionRowBuilder,@@ -213,6 +218,16 @@ const staffMessage = await getTicketContainer(ticket, "closed", false);
// send message to the author try { + const thankYou = new ActionRowBuilder<ButtonBuilder>().addComponents( + new ButtonBuilder() + .setCustomId(`ticket:thank:${ticket.id}`) + .setLabel("Thank your moderator") + .setEmoji("💖") + .setStyle(ButtonStyle.Primary), + ); + + publicMessage.container.addActionRowComponents(thankYou); + await author.send({ components: [publicMessage.container], flags: ["IsComponentsV2"],@@ -261,6 +276,61 @@ await interaction.followUp({
content: "⚠️ Ticket closed but failed to send transcript to transcript channel.", }); + } +} + +export async function handleThank( + _client: Client, + interaction: ButtonInteraction, +) { + await interaction.deferReply({ flags: ["Ephemeral"] }); + const id = Number(interaction.customId.split(":")[2]); + + const { data: ticket, exists } = await db + .select() + .from(tickets) + .where(eq(tickets.id, id)) + .then(([result]) => ({ data: result, exists: !!result })); + + if (!exists || !ticket) { + await interaction.reply("❌ Ticket not found."); + return; + } + + if (!ticket.channelId) { + logger.error( + `Ticket ${ticket.id} does not have a channelId, cannot send thank you message`, + ); + await interaction.editReply( + "⚠️ Ticket data is missing channel information, cannot send thank you message.", + ); + return; + } + + try { + const channel = await _client.channels.fetch(ticket.channelId); + if (!channel || !("send" in channel)) { + logger.error( + `Channel with ID ${ticket.channelId} not found or is not a text channel for ticket ${ticket.id}`, + ); + await interaction.editReply( + "⚠️ Could not find the ticket channel to send the thank you message.", + ); + return; + } + + await channel.send( + "The reporter says thank you for handling this ticket! 💖", + ); + await interaction.editReply("A thank you message sent to the moderators!"); + } catch (error) { + logger.error( + error, + `Could not send thank you message to moderator for ticket ${ticket.id}`, + ); + await interaction.editReply( + "⚠️ Failed to send thank you message to the moderator.", + ); } }
M
src/interactions/commands/tickets/index.ts
→
src/interactions/commands/tickets/index.ts
@@ -15,6 +15,7 @@ handleClose,
handleCreate, handleDelete, handleReopen, + handleThank, handleTranscript, } from "./actions"; import {@@ -163,6 +164,11 @@
async function buttonExecute(client: Client, interaction: ButtonInteraction) { const [action] = interaction.customId.split(":").slice(1); + if (action === "thank") { + await handleThank(client, interaction); + return; + } + if (!interaction.channelId || !interaction.guildId) { await interaction.reply({ content: "This command can only be used in a server.",@@ -174,7 +180,6 @@ if (action === "list") {
await handleListPagination(client, interaction); return; } - if (action === "create") { await handleCreate(client, interaction); return;