# ModalHandler

`class` in `seedcord` · v0.12.0

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

Base class for a modal submit handler.

Register the customId definitions this handler decodes with `@ModalRoute`, list the same ones in the generic, then read `this.params` for a single route or `this.match` for several. Read the submitted inputs from `this.event.fields`.

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

## Examples

```ts
\@ModalRoute(ConfigId)
class ConfigModal extends ModalHandler<[typeof ConfigId]> {
    \@Catchable()
    async execute() {
        const { guildId } = this.params;
        const name = this.event.fields.getTextInputValue('name');
        await this.event.reply(`saved ${name} for ${guildId}`);
    }
}
```
