import { Subcommand } from "@sapphire/plugin-subcommands"; import { ApplyOptions } from "@sapphire/decorators"; import { container } from "@sapphire/framework"; @ApplyOptions({ description: "ticket-related commands", }) export class TicketCommand extends Subcommand { public constructor(context: Subcommand.LoaderContext, options: Subcommand.Options) { super(context, { ...options, name: "ticket", subcommands: [ { name: "new", chatInputRun: "createTicket" }, { name: "for", chatInputRun: "createTicketFor" }, { name: "actions", type: "group", entries: [ { name: "open", chatInputRun: "openTicket" }, { name: "close", chatInputRun: "closeTicket" }, { name: "add", chatInputRun: "addToTicket" }, { name: "claim", chatInputRun: "claimTicket" }, { name: "unclaim", chatInputRun: "unclaimTicket" }, { name: "delete", chatInputRun: "deleteTicket" }, ], }, { name: "view", type: "group", entries: [ { name: "info", chatInputRun: "viewTicketInfo" }, { name: "transcript", chatInputRun: "viewTicketTranscript" }, { name: "list", chatInputRun: "listTickets" }, { name: "export", chatInputRun: "exportTickets" }, ], }, ], }); } public override registerApplicationCommands(registry: Subcommand.Registry) { registry.registerChatInputCommand((builder) => builder .setName("ticket") .setDescription("root ticket command") .addSubcommand((command) => command.setName("new").setDescription("Open a new ticket")) .addSubcommandGroup((group) => group .setName("action") .setDescription("ticket actions") .addSubcommand((command) => command.setName("open").setDescription("Reopen the ticket in the current channel"), ) .addSubcommand((command) => command .setName("close") .setDescription("Close the ticket in the current channel") .addStringOption((option) => option .setName("reason") .setDescription("Public reason for closing the ticket") .setRequired(true), ) .addStringOption((option) => option .setName("private") .setDescription( "Private reason for closing the ticket, only visible to moderators", ) .setRequired(false), ) .addBooleanOption((option) => option.setName("delete-channel").setDescription("Delete the channel immediately"), ), ), ), ); } public async createTicket(interaction: Subcommand.ChatInputCommandInteraction) { interaction.reply({ content: "Ticket created!" }); } public async openTicket(interaction: Subcommand.ChatInputCommandInteraction) { interaction.reply({ content: "Ticket opened!" }); } public async closeTicket(interaction: Subcommand.ChatInputCommandInteraction) { interaction.reply({ content: "Ticket closed!" }); } } container.stores.loadPiece({ piece: TicketCommand, name: "ticket", store: "commands", });