all repos — stealth-developers @ db85926ebb52728665b7609c703847ecce689633

bot: command & button to delete ticket channels
vi did:web:vt3e.cat
Sat, 27 Jun 2026 02:46:59 +0100
commit

db85926ebb52728665b7609c703847ecce689633

parent

e24ca93b2bb2cef8fa9c346db7bb7f07bada0973

M apps/bot/src/feats/tickets/README.mdapps/bot/src/feats/tickets/README.md

@@ -2,14 +2,14 @@ - [ ] /ticket

- [x] new - [x] for - [x] view [ticketId] - - [ ] actions + - [x] actions - [x] close - [x] reopen - [x] claim - [x] unclaim - [x] comment [ticketId?] - [x] edit [ticketId?] - - [ ] clean - /ticket delete + - [x] clean - /ticket delete - [ ] participants - [ ] add - [ ] remove
M apps/bot/src/feats/tickets/actions.tsapps/bot/src/feats/tickets/actions.ts

@@ -540,6 +540,18 @@

return newTicket; } +export async function cleanTicket(ctx: TicketContext) { + const { ticket, actor, ticketChannel, guild } = ctx; + if (ticket.status !== "closed") + throw new Error("Tickets must be closed before they can be cleaned up."); + + const canAccess = hasAccessToTicket(actor, guild, ticket, { requireModerator: true }); + if (!canAccess) throw new PublicError("You don't have permission to clean up this ticket."); + if (!ticketChannel) throw new PublicError("Ticket channel not found."); + + return await ticketChannel.delete("Ticket channel cleaned up"); +} + export async function canDmUser(user: AnyUser): Promise<boolean> { if (!("send" in user)) return false;
M apps/bot/src/feats/tickets/buttons.tsapps/bot/src/feats/tickets/buttons.ts

@@ -177,11 +177,18 @@ );

}, }); -export const cleanTicketButton = kitten.button("b-delete-ticket", { +export const cleanTicketButton = useGetTicketData.button("b-delete-ticket", { options: { ticketId: option.string({ required: true }), }, - async run() {}, + async run(interaction, _, ctx) { + const { actor, ticket, ticketChannel, guild } = ctx; + if (!ticket || !ticketChannel || !actor || !guild) + return errorMessage(interaction, "Failed to find ticket"); + + const result = await Result.fromAsync(actions.cleanTicket(ctx)); + if (result.isErr()) return errorMessage(interaction, "Failed to delete ticket channel"); + }, }); export const thankButton = kitten.button("b-thank-ticket", {
M apps/bot/src/feats/tickets/commands.tsapps/bot/src/feats/tickets/commands.ts

@@ -237,7 +237,18 @@ }),

); }, }); - // TODO)) clean + + group.subcommand("delete", { + description: "Delete the ticket channel", + async run(interaction, _, ctx) { + const { actor, ticket, ticketChannel, guild } = ctx; + if (!ticket || !ticketChannel || !actor || !guild) + return errorMessage(interaction, "Failed to find ticket"); + + const result = await Result.fromAsync(actions.cleanTicket(ctx)); + if (result.isErr()) return errorMessage(interaction, "Failed to delete ticket channel"); + }, + }); }, );