Notice
Base class for a user-facing refusal or a reported fault.
Throw a Notice to stop a handler and reply to the user. The framework catches it at the controller
boundary and renders render, which always determines what the user sees. With report
false that render is all that happens. With report true the framework also logs the fault and
publishes it to the handledException bus. A raw, non-Notice throw shows the generic message.
abstract class Notice extends Errorimport { Notice, BuilderComponent, type RenderContext, type ReplyResponse } from '@seedcord/gateway';
import { TextDisplayBuilder } from '@discordjs/builders';
// reading `.component` applies the configured bot color to the container accent
class TooPoorCard extends BuilderComponent<'container'> {
constructor(balance: number) {
super('container');
this.instance.addTextDisplayComponents(
new TextDisplayBuilder().setContent(`### Insufficient balance\nYou need more than ${balance} coins.`)
);
}
}
class TooPoor extends Notice {
constructor(private readonly balance: number) {
super(`balance ${balance} is below the cost`);
}
override render(_ctx: RenderContext): ReplyResponse {
return { components: [new TooPoorCard(this.balance).component] };
}
}
// in a handler, throwing stops the handler and replies with render(ctx)
if (wallet.balance < cost) throw new TooPoor(wallet.balance);Member visibility
Filter class members by access level.
protected Notice(message: string, options?: ErrorOptions)public ephemeral: booleanDefault:true
Whether this denial is a reported fault. True also logs it and publishes it to the handledException
bus. The user always sees render either way.
public report: booleanDefault:false
A short one-line reason. When every gate in an or refuses and each one sets this, or
throws a refusal listing them under You need to meet at least one of these:. Write a verb phrase that
finishes that line, for example, "be the bot owner".
public summary?: stringpublic render(_ctx: RenderContext): ReplyResponse