# defineEffectGate

`function` in `seedcord` · v0.14.0

<https://docs.seedcord.org/packages/seedcord/0.14.0/functions/define-effect-gate>

Builds an [`EffectGate`](/packages/seedcord/0.14.0/interfaces/effect-gate) from a `check` and a `commit`. `check` peeks and refuses by throwing, and `commit` applies the side effect, running only once the whole gate set passes so a later refusal never commits. In an `or`, a refusing arm's queued commit is rolled back. This is how [`Cooldown`](/packages/seedcord/0.14.0/functions/cooldown) peeks in `check` and charges the slot in `commit`.

```ts
defineEffectGate<Name, Ctx>(
    name: Name,
    check: (ctx: Ctx) => void | Promise<void>,
    commit: (ctx: Ctx) => void | Promise<void>
): EffectGate<Ctx, Name>
```

Builds an [`EffectGate`](/packages/seedcord/0.14.0/interfaces/effect-gate) from a `check` and a `commit`. `check` peeks and refuses by throwing, and `commit` applies the side effect, running only once the whole gate set passes so a later refusal never commits. In an `or`, a refusing arm's queued commit is rolled back. This is how [`Cooldown`](/packages/seedcord/0.14.0/functions/cooldown) peeks in `check` and charges the slot in `commit`.

Parameters.

- `name` `Name` — The gate's name, used in mismatch errors.
- `check` `(ctx: Ctx) => void | Promise<void>` — Peeks and refuses by throwing, without applying the side effect.
- `commit` `(ctx: Ctx) => void | Promise<void>` — Applies the side effect, running only after the whole gate set passes.

Returns `EffectGate<Ctx, Name>`.
