# ButtonHandler

`class` in `seedcord` · v0.12.0

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

Base class for a button interaction handler.

Register the customId definitions this handler decodes with `@ButtonRoute`, list the same ones in the generic, then read `this.params` for a single route or `this.match` for several. Passing different definitions to the decorator and the generic is a compile error.

```ts
abstract class ButtonHandler<
    Defs extends readonly AnyCustomId[],
    Cache extends CacheType = "cached"
> extends ComponentHandler<ButtonInteraction<Cache>, Defs>
```

## Examples

```ts
\@ButtonRoute(ApproveId)
class ApproveButton extends ButtonHandler<[typeof ApproveId]> {
    \@Catchable()
    async execute() {
        const { userId } = this.params;
        await this.event.reply(`approved <@${userId}>`);
    }
}
```
