bot: command & button to delete ticket channels
vi did:web:vt3e.cat
Sat, 27 Jun 2026 02:46:59 +0100
4 files changed,
35 insertions(+),
5 deletions(-)
M
apps/bot/src/feats/tickets/README.md
→
apps/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.ts
→
apps/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/commands.ts
→
apps/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"); + }, + }); }, );