kitten: add replyPayload to HaltExecution error
vi did:web:vt3e.cat
Sun, 21 Jun 2026 22:27:22 +0100
3 files changed,
16 insertions(+),
4 deletions(-)
M
pkgs/router/package.json
→
pkgs/router/package.json
@@ -1,6 +1,6 @@
{ "name": "@purrkit/router", - "version": "1.0.3", + "version": "1.1.0", "license": "EUPL-1.2", "author": { "name": "apr",
M
pkgs/router/src/errors.ts
→
pkgs/router/src/errors.ts
@@ -1,6 +1,9 @@
+import { InteractionReplyOptions } from "discord.js"; + export class HaltExecution extends Error { - constructor() { - super("execution stopped by middleware"); + constructor(public replyPayload?: string | InteractionReplyOptions) { + super("execution halted by middleware."); + this.name = "HaltExecution"; } }
M
pkgs/router/src/kitten.ts
→
pkgs/router/src/kitten.ts
@@ -245,7 +245,16 @@ } else {
await run(interaction, context); } } catch (err) { - if (err instanceof HaltExecution) return; + if (err instanceof HaltExecution) { + if (err.replyPayload && !interaction.replied && !interaction.deferred) { + const replyOptions = + typeof err.replyPayload === "string" + ? { content: err.replyPayload, ephemeral: true } + : err.replyPayload; + await interaction.reply(replyOptions).catch(() => null); + } + return; + } this.logger.error(`unhandled error executing command ${interaction.commandName}:`, { error: err instanceof Error ? err.stack : String(err),