CIRCE / DOCUMENTATION
Middleware
Global before and after hooks around every interaction.
src/middleware.ts wraps commands, context menus, components and modals.
defineMiddleware({
before?(ctx: MiddlewareContext): void | Promise<void>,
after?(ctx: MiddlewareContext): void | Promise<void>,
});
interface MiddlewareContext {
kind: "command" | "context-menu" | "component" | "modal";
name: string; // command name or customId
logger: Logger;
correlationId: string | undefined;
}
import { defineMiddleware } from "@sxnnyside/circe";
export default defineMiddleware({
async before(ctx) {
ctx.logger.debug(`start ${ctx.kind}:${ctx.name}`);
},
async after(ctx) {
ctx.logger.debug(`done ${ctx.kind}:${ctx.name}`);
},
});
The context has no interaction. For per-handler checks use guards; for metrics use onInteractionComplete (Health).
