Functiongatewayv0.11.0
getConfirmation
Shows a confirm/cancel prompt with built-in Confirm and Cancel buttons and resolves to true only if the
invoking user clicks confirm. A cancel click or a timeout resolves to false. Gate the action behind it
with an early return. A ModalHandler is excluded at compile time.
Throws:
The send error when the prompt fails to send. The handler's fault boundary catches it.
async getConfirmation(
handler: RepliableHandler<NonModalInteraction>,
prompt: string,
options?: DefaultConfirmOptions
): Promise<boolean>import { getConfirmation } from '@seedcord/gateway';
\@SlashRoute('ban')
class BanHandler extends SlashHandler<'ban'> {
async execute() {
const target = this.options.getUser('target');
if (!(await getConfirmation(this, `Ban ${target.tag}? This cannot be undone.`))) return;
await this.event.guild?.members.ban(target.id);
}
}handler
handler: RepliableHandler<NonModalInteraction>The handler to prompt from, this inside a non-modal handler.
prompt
prompt: stringThe message shown above the Confirm and Cancel buttons.
options?
options?: DefaultConfirmOptionsEphemeral flag, timeout, the built-in buttons' labels and style, and the optional
onConfirm/onCancel/onTimeout outcome replies that edit the prompt in place.