import { InteractionReplyOptions } from "discord.js"; /** * throw this inside a middleware to intentionally halt execution without triggering * the error handler propagation chain. * * @example * ```ts * kitten.builder().use(async (interaction) => { * if (!isAuthorized) { * throw new HaltExecution({ content: "unauthorized.", flags: ["Ephemeral"] }); * } * }); * ``` */ export class HaltExecution extends Error { constructor(public replyPayload?: string | InteractionReplyOptions) { super("execution halted by middleware."); this.name = "HaltExecution"; } } /** * thrown when a generated custom ID exceeds discord's 100 character limit. * * @remarks * this usually happens when you store too much dynamic data in a component's options, * or if your component name is exceptionally long. * * kitten will warn you if you're close to the limit (subscribe to the `warn` event), but * this error will be thrown if you exceed it. */ export class CustomIdTooLong extends Error { constructor(componentName: string, length: number) { super( `custom ID for component "${componentName}" is too long (${length} characters). discord limits custom IDs to 100 characters.`, ); } }