all repos — stealth-developers @ dc9f36286fdd4c5a333e2925b28604d4cdef7f24

feat(tickets): claim on message, change channel name after unclaiming
vi did:web:vt3e.cat
Sat, 09 May 2026 04:42:45 +0100
commit

dc9f36286fdd4c5a333e2925b28604d4cdef7f24

parent

d50a9160254db7ccf1b406556ecb9eb21de84383

M src/events/messageCreate.tssrc/events/messageCreate.ts

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

import { AttachmentBuilder, + ChannelType, type Client, Events, type GuildMember,

@@ -181,6 +182,18 @@ )

.get(); if (!ticket) return; + + try { + const isClaimed = ticket.claimedBy; + if (!isClaimed) { + db.update(tickets) + .set({ claimedBy: message.author.id, claimedAt: message.createdAt }) + .where(eq(tickets.id, ticket.id)); + + if (message.channel.type === ChannelType.GuildText) + message.channel.setName(`claimed-${ticket.ticketNumber}`); + } + } catch {} try { const isSystem = message.author.id === client.user.id;
M src/interactions/commands/tickets/_shared.tssrc/interactions/commands/tickets/_shared.ts

@@ -32,7 +32,9 @@ } as const;

// -- modals --------------------------------------------------------------------------------------- export function getTicketReasonModal(staff = false) { - const modal = new ModalBuilder().setCustomId(MODAL_IDS.reason).setTitle("Close Ticket"); + const modal = new ModalBuilder() + .setCustomId(MODAL_IDS.reason) + .setTitle("Close Ticket"); const pubReason = new LabelBuilder() .setLabel("Public Reason")

@@ -52,7 +54,9 @@ );

const privateReason = new LabelBuilder() .setLabel("Private Reason") - .setDescription("Provide a reason for closing the ticket - this will only be visible to staff") + .setDescription( + "Provide a reason for closing the ticket - this will only be visible to staff", + ) .setTextInputComponent( new TextInputBuilder() .setCustomId(INPUT_IDS.PRIVATE_REASON)

@@ -65,7 +69,9 @@

const deleteGroup = new LabelBuilder() .setLabel("Immediately delete channel") .setCheckboxComponent( - new CheckboxBuilder().setCustomId("ticket:delete_checkbox").setDefault(false), + new CheckboxBuilder() + .setCustomId("ticket:delete_checkbox") + .setDefault(false), ); modal.addLabelComponents(pubReason);

@@ -116,8 +122,12 @@ );

} const wasBehalfTicket = ticket.openedBy !== ticket.authorId; - const reasonText = ticket.topic ? `for reason: ${ticket.topic}` : "without a provided reason"; - const behalfText = wasBehalfTicket ? `**Opened By**: <@${ticket.openedBy}> ${reasonText}` : null; + const reasonText = ticket.topic + ? `for reason: ${ticket.topic}` + : "without a provided reason"; + const behalfText = wasBehalfTicket + ? `**Opened By**: <@${ticket.openedBy}> ${reasonText}` + : null; const container = new ContainerBuilder() .addTextDisplayComponents(

@@ -140,7 +150,9 @@ .filter(Boolean)

.join("\n"), ), ) - .addSeparatorComponents(new SeparatorBuilder().setDivider(false).setSpacing(2)) + .addSeparatorComponents( + new SeparatorBuilder().setDivider(false).setSpacing(2), + ) .addTextDisplayComponents( text( [

@@ -175,7 +187,12 @@ )

.join(", "); return { - container: constructTicketContainer(ticket, attachmentsString, context, isPublic), + container: constructTicketContainer( + ticket, + attachmentsString, + context, + isPublic, + ), transcriptText, attachments, files: [file],
M src/interactions/commands/tickets/actions.tssrc/interactions/commands/tickets/actions.ts

@@ -758,6 +758,10 @@ });

return; } + if (interaction.channel!.type === ChannelType.GuildText) { + await interaction.channel!.setName(`ticket-${ticket.ticketNumber}`); + } + await db .update(tickets) .set({