# getConfirmation

`function` in `gateway` · v0.6.0

<https://docs.seedcord.org/packages/gateway/0.6.0/functions/get-confirmation>

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 failed prompt send throws into the fault boundary. A [`ModalHandler`](/packages/gateway/0.6.0/classes/modal-handler) is excluded at compile time.

## Signature 1

```ts
async getConfirmation(
    handler: RepliableHandler<NonModalInteraction>,
    prompt: string,
    options?: DefaultConfirmOptions
): Promise<boolean>
```

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 failed prompt send throws into the fault boundary. A [`ModalHandler`](/packages/gateway/0.6.0/classes/modal-handler) is excluded at compile time.

Parameters.

- `handler` `RepliableHandler<NonModalInteraction>` — The handler to prompt from, `this` inside a non-modal handler.
- `prompt` `string` — The message shown above the Confirm and Cancel buttons.
- `options?` `DefaultConfirmOptions` — Ephemeral flag, timeout, the built-in buttons' labels and style, and the optional `onConfirm`/`onCancel`/`onTimeout` outcome replies that edit the prompt in place.

Returns `Promise<boolean>`.

## Signature 2

```ts
async getConfirmation(
    handler: RepliableHandler<NonModalInteraction>,
    prompt: (ids: {
        confirm: string;
        cancel: string;
    }) => Promisable<ReplyResponse>,
    options?: ConfirmOptions
): Promise<boolean>
```

Shows a confirm/cancel prompt you build yourself and resolves to `true` only if the invoking user clicks confirm. The factory receives the two minted button ids. Set them on your own buttons. A cancel click or a timeout resolves to `false`. A failed prompt send throws into the fault boundary. A [`ModalHandler`](/packages/gateway/0.6.0/classes/modal-handler) is excluded at compile time.

The prompt is collected in-process, so it does not survive a bot restart. Without an outcome hook the prompt is gone once the user confirms, so deliver the result with a fresh `this.followUp(...)`.

Parameters.

- `handler` `RepliableHandler<NonModalInteraction>` — The handler to prompt from, `this` inside a non-modal handler.
- `prompt` `(ids: { confirm: string; cancel: string; }) => Promisable<ReplyResponse>` — A factory given the minted `{ confirm, cancel }` ids that returns the reply to show. Build it with the `BuilderComponent` and `RowComponent` wrappers.
- `options?` `ConfirmOptions` — Ephemeral flag, timeout, and the optional `onConfirm`/`onCancel`/`onTimeout` outcome replies that edit the prompt in place.

Returns `Promise<boolean>`.
