# RepliableHandler

`class` in `core` · v0.12.0

<https://seedcord.org/docs/packages/core/0.12.0/classes/repliable-handler>

Shared base the repliable handlers on both transports extend. Defines the reply members over one sender.
The dispatch run builds that sender and passes it to the handler and each middleware.

```ts
abstract class RepliableHandler<
    Event,
    TCore extends CoreBase,
    TMessage extends { id: string },
    TNative,
    TSender extends BaseReplySender<TMessage, TNative>
> extends BaseHandler<Event, TCore>
```

## Constructors

### constructor

```ts
protected RepliableHandler(
    event: Event,
    core: TCore,
    dispatch: DispatchContext,
    sender: TSender
)
```

Constructs a new instance of the `RepliableHandler` class

## Properties

### core

```ts
readonly core: TCore
```

### dispatch

```ts
protected readonly dispatch: DispatchContext
```

The bag for this dispatch. Each interaction gets its own. Every handler for one event shares a single bag.

### event

```ts
protected readonly event: Event
```

### logger

```ts
protected readonly logger: Logger
```

### route

```ts
protected readonly route: string
```

The route that started this dispatch. Each handler base narrows it to its own routes.

### sender

```ts
public readonly sender: TSender
```

The reply surface for this interaction. Pass the handler to reply from outside its class.

## Methods

### defer

```ts
protected async defer(opts?: DeferOpts): Promise<void>
```

Show a "thinking" placeholder, then fill it later with [`edit`](/docs/packages/core/0.12.0/classes/base-reply-sender#edit).

### delete

```ts
protected async delete(target?: TMessage): Promise<void>
```

Delete the initial reply or deferred placeholder. Pass a target to delete a message a prior send returned.

### edit

```ts
protected async edit(
    response: ReplyResponse<TNative> | string
): Promise<TMessage>
```

```ts
protected async edit(
    target: TMessage,
    response: ReplyResponse<TNative> | string
): Promise<TMessage>
```

Rewrite the initial reply or deferred placeholder. The targeted form rewrites a message a prior send returned.

### execute

```ts
abstract execute(): Promisable<void>
```

Holds the main logic of your handler. The dispatcher calls it after the handler's gates pass, so a
gate that refuses stops `execute()` from running.

### followUp

```ts
protected async followUp(
    response: ReplyResponse<TNative> | string,
    opts?: SendOpts
): Promise<TMessage>
```

Send a new message once the interaction is acknowledged.

### reply

```ts
protected async reply(
    response: ReplyResponse<TNative> | string,
    opts?: SendOpts
): Promise<TMessage>
```

Send the initial response, exactly once.

### send

```ts
protected async send(
    response: ReplyResponse<TNative> | string,
    opts?: SendOpts
): Promise<TMessage>
```

Routes to reply, followUp, or edit based on the current ack state.
