# Gated

`function` in `http` · v0.1.0-next.0

<https://docs.seedcord.org/packages/http/0.1.0-next.0/functions/gated>

Attaches gates to an HTTP interaction handler. The gates run before `execute`, and a gate refusing stops the handler with the reply or drop the gate threw. Multiple gates are ANDed, so each must pass. A gate that requires a context the handler does not provide (a button gate on a slash handler, a gate on an autocomplete handler, or a `RequirePermissions([...], { in: 'guild' })` gate the http transport cannot satisfy) is a compile error at this line, and the error names the gate and the handler kind. Place it above the route decorator.

Combine gates with [`and`](/packages/core/0.1.0-next.5/functions/and) or [`or`](/packages/core/0.1.0-next.5/functions/or) to build a single gate from multiple arms.

```ts
Gated<Gates>(
    gates: Gates
): <TCtor extends AnyHandlerCtor>(
    ctor: FitAll<TCtor, Gates> extends Gates
        ? TCtor
        : FitAll<TCtor, Gates>
) => void
```

Attaches gates to an HTTP interaction handler. The gates run before `execute`, and a gate refusing stops the handler with the reply or drop the gate threw. Multiple gates are ANDed, so each must pass. A gate that requires a context the handler does not provide (a button gate on a slash handler, a gate on an autocomplete handler, or a `RequirePermissions([...], { in: 'guild' })` gate the http transport cannot satisfy) is a compile error at this line, and the error names the gate and the handler kind. Place it above the route decorator.

Combine gates with [`and`](/packages/core/0.1.0-next.5/functions/and) or [`or`](/packages/core/0.1.0-next.5/functions/or) to build a single gate from multiple arms.

Parameters.

- `gates` `Gates` — One or more gates to attach, each ANDed so the handler runs only when all pass.

Returns `<TCtor extends AnyHandlerCtor>(ctor: FitAll<TCtor, Gates> extends Gates ? TCtor : FitAll<TCtor, Gates>) => void`.
