# BaseReplySender

`class` in `core` · v0.1.0-next.5

<https://docs.seedcord.org/packages/core/0.1.0-next.5/classes/base-reply-sender>

Tracks acknowledgement state and throws a translated `SeedcordError` on an illegal verb before any transport call. Verbs execute the legality check, control the transport wire writer, then update the state and ack trace. Each transport binds `TMessage` to its created-message lens and supplies the writers.

```ts
abstract class BaseReplySender<TMessage extends { id: string }>
```

## Constructors

### constructor

```ts
protected BaseReplySender(
    routeId: string,
    initialState?: AckState
)
```

Constructs a new instance of the `BaseReplySender` class

## Properties

### id

```ts
public id: string
```

### routeId

```ts
protected readonly routeId: string
```

## Methods

### defer

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

### deferUpdate

```ts
public async deferUpdate(): Promise<void>
```

### delete

```ts
public async delete(): Promise<void>
```

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

### edit

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

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

### followUp

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

### guardModalSource

```ts
protected guardModalSource(): void
```

### remember

```ts
protected remember(created: TMessage): TMessage
```

### reply

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

### send

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

Routes to the verb the current ack state permits. Every state has a route, so the illegal-ack throw is unreachable.

### serialize

```ts
protected serialize(
    response: ReplyResponse | string
): SerializedReply
```

### showModal

```ts
public async showModal(
    modal: ModalLike
): Promise<void>
```

Must be the initial response.

### update

```ts
public async update(
    response: ReplyResponse | string
): Promise<TMessage>
```

After a deferUpdate the state stays deferred-update, so the rewrite repeats. The returned message is the source message, editable only through a bare `update` or `edit`. A targeted `edit` or `delete` of it throws the foreign-target error.

### writeDefer

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

### writeDeferUpdate

```ts
protected abstract async writeDeferUpdate(): Promise<void>
```

### writeDeleteOriginal

```ts
protected abstract async writeDeleteOriginal(): Promise<void>
```

### writeDeleteTarget

```ts
protected abstract async writeDeleteTarget(
    targetId: string
): Promise<void>
```

### writeEditOriginal

```ts
protected abstract async writeEditOriginal(
    response: ReplyResponse | string
): Promise<TMessage>
```

### writeEditTarget

```ts
protected abstract async writeEditTarget(
    targetId: string,
    response: ReplyResponse | string
): Promise<TMessage>
```

### writeFollowUp

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

### writeModal

```ts
protected abstract async writeModal(
    data: APIModalInteractionResponseCallbackData
): Promise<void>
```

### writeReply

```ts
protected abstract async writeReply(
    response: ReplyResponse | string,
    opts?: SendOpts
): Promise<TMessage | undefined>
```

### writeUpdate

```ts
protected abstract async writeUpdate(
    response: ReplyResponse | string
): Promise<TMessage | undefined>
```
