# ComponentHandler

`class` in `seedcord` · v0.14.0

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

Shared base the customId-routed component handlers extend.

Not a public entry point. You should be using [`ButtonHandler`](/packages/seedcord/0.14.0/classes/button-handler), [`SelectHandler`](/packages/seedcord/0.14.0/classes/select-handler), or [`ModalHandler`](/packages/seedcord/0.14.0/classes/modal-handler) instead. This class only carries the customId decode and route-matching plumbing those bases share, so DO NOT use it directly.

```ts
abstract class ComponentHandler<
    Event extends ComponentInteraction,
    Defs extends readonly AnyCustomId[]
>
    extends InteractionHandler<Event>
    implements HasComponentDefs<Defs>
```

## Constructors

### constructor

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

Constructs a new instance of the `InteractionHandler` class

## Properties

### __componentDefs

```ts
public 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.
