# SlashHandler

`class` in `http` · v0.1.0-next.0

<https://docs.seedcord.org/packages/http/0.1.0-next.0/classes/slash-handler>

Base class for a chat-input (slash) command handler on the HTTP transport.

Pass the route from the generated registry as the generic, then read `this.options` for a single command or `this.match` for several. Command authoring stays plain discord.js, `seedcord codegen` reads its `toJSON()` to type these options.

```ts
abstract class SlashHandler<
    Route extends keyof SlashOptionRegistry
> extends InteractionHandler<APIChatInputApplicationCommandInteraction>
```

## Constructors

### constructor

```ts
InteractionHandler(
    event: Event,
    core: Core,
    dispatch?: DispatchContext
)
```

Constructs a new instance of the `InteractionHandler` class

## Properties

### options

```ts
protected options: SlashOptions<Route>
```

The typed options for this command's route. Required options drop the null, choices narrow to their literal union, and only the getters for kinds this command actually uses appear. Rich kinds resolve from the interaction's `resolved` data.

## Methods

### buildSender

```ts
protected buildSender(
    event: Event,
    core: Core,
    routeId: string
): ReplySender
```

### match

```ts
protected async match<Ret>(
    arms: SlashMatchArms<Route, Ret>
): Promise<Ret>
```

Run the arm for whichever command fired. Use this only when the handler is registered for several routes.

Provide one arm per registered route, keyed by its route string, and each arm receives that route's own narrowed options. The arms must cover every route in the generic, a missing route or an unknown key is a compile error.

### showModal

```ts
protected async showModal(
    this: InteractionHandler<
        Exclude<Repliables, APIModalSubmitInteraction>
    >,
    modal: ModalLike
): Promise<void>
```

Open a modal. Must be the initial response to this interaction. The modal kind rejects this call at compile time (Discord forbids a modal in response to a modal).
