# SelectHandler

`class` in `seedcord` · v0.14.0

<https://docs.seedcord.org/packages/seedcord/0.14.0/classes/select-handler>

Base class for a select menu handler.

Pass the select kind first and the customId definitions second, the same order as `@SelectMenuRoute`, so `this.event` and `this.event.values` are narrowed to that kind. Read `this.params` for a single route or `this.match` for several.

```ts
abstract class SelectHandler<
    Kind extends SelectMenuKind,
    Defs extends readonly AnyCustomId[],
    Cache extends CacheType = "cached"
> extends ComponentHandler<SelectMenuInteractionFor<Kind, Cache>, Defs>
```

## Examples

```ts
\@SelectMenuRoute(SelectMenuKind.User, AssignId)
class AssignSelect extends SelectHandler<SelectMenuKind.User, [typeof AssignId]> {
    async execute() {
        const { roleId } = this.params;
        await this.event.reply(`assigning ${this.event.values.length} member(s) to <@&${roleId}>`);
    }
}
```

## Constructors

### constructor

```ts
InteractionHandler(event: Repliable, core: Core)
```

Constructs a new instance of the `InteractionHandler` class

## Properties

### __componentDefs

```ts
readonly __componentDefs: Defs
```

### core

```ts
readonly core: Core
```

### event

```ts
protected readonly event: ValidEvent
```

### logger

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

### params

```ts
protected params: SingleParams<Defs>
```

The decoded params of the single route this handler is registered for.

Reading this decodes `this.event.customId` once (cached after the first read) and throws `StaleCustomId` or `InvalidCustomId` when the wire no longer matches the current shape, which the controller boundary turns into a reply. On a handler registered for several routes this is `never`, so use [`match`](/packages/seedcord/0.14.0/classes/autocomplete-handler#match) instead.

## Methods

### execute

```ts
abstract async execute(): Promise<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.

### match

```ts
protected async match<Ret>(arms: MatchArms<Defs, Ret>): Promise<Ret>
```

Run the arm for whichever route the component was minted from. Use this only when the handler is registered for several routes. A single-route handler reads `this.params` directly. On a multi-route handler `this.params` is `never`, so match is the only way to read the decoded params.

Provide one arm per registered route, keyed by its prefix, and each arm receives that route's own decoded params. The arms must cover every registered def, a missing prefix or an unknown key is a compile error. Decoding runs before any arm, so a stale or corrupt wire throws before an arm body executes.
