Skip to content
Functionhttpv0.14.0Decorator

Gated

Attaches gates to an HTTP interaction handler. The gates run before execute, and a gate refusing stops the handler with the reply or Silence that the gate threw. Multiple gates are ANDed. A gate that requires a context that 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 message shows the gate and the handler kind. Place it above the route decorator.

Combine gates into a single gate with and or or.

See also:defineGate, defineEffectGate

Gated<Gates>(
    gates: Gates
): <TCtor extends AnyHandlerCtor>(
    ctor: FitAll<TCtor, Gates> extends Gates
        ? TCtor
        : FitAll<TCtor, Gates>
) => void
import { PermissionFlagsBits } from 'discord-api-types/v10';

\@Gated(GuildOnly(), RequirePermissions([PermissionFlagsBits.ManageMessages]))
\@SlashRoute('purge')
class Purge extends SlashHandler<'purge'> {
    async execute() {
        // both gates passed, so this runs in a guild with a caller who can moderate this channel
    }
}

Gates

The non-empty tuple of gates to run, in order, against the handler's context.

Gates

The non-empty tuple of gates to run, in order, against the handler's context.

gates

gates: Gates

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