Skip to content
Interfacehttpv0.14.0

InteractionGateContext

The interaction gate context on the HTTP transport. It extends the scalar AppPermissionsContext with the raw interaction payload and the user and member in the payload. A gate reading button fields, inferred from its ctx annotation, is rejected on a slash handler.

memberGuildPermissions and appGuildPermissions are absent because the http transport doesn't deliver role-derived permission sets. A gate requiring GuildPermissionsContext (a permission gate with in: 'guild') is a compile error on an http handler.

interface InteractionGateContext<
    Repliable extends Repliables = Repliables
> extends AppPermissionsContext
import type { APIMessageComponentButtonInteraction } from 'discord-api-types/v10';

// a button-only gate: the Repliable generic narrows which handlers accept it
const ButtonGate = defineGate('btn', (ctx: InteractionGateContext<APIMessageComponentButtonInteraction>) => {
    void ctx.interaction; // APIMessageComponentButtonInteraction
});

Repliable

The interaction type the gate reads, narrowing which handlers accept it.

Repliable extends Repliables = Repliables

appPermissions

The bot's permissions in the invoked channel, the wire app_permissions value.

readonly appPermissions: bigint

Inherited from:AppPermissionsContext

core

readonly core: Core

dispatch

The bag for this dispatch, the same instance the handler and its middleware hold. Every middleware runs before the first gate. A gate can therefore read what a middleware wrote.

readonly dispatch: DispatchContext

Inherited from:GateContextBase

guildLocale

The guild's preferred language, or null outside a guild.

readonly guildLocale: Locale | null

Inherited from:DispatchOrigin

interaction

The raw interaction payload, which is the reply target.

readonly interaction: Repliable

kind

Narrow on this before reading interaction.

readonly kind: 'interaction'

memberPermissions

The member's permission bits, or null outside a guild. On an interaction these are the channel-scoped permissions the payload contains, and on a gateway event they're the member's guild-level ones.

readonly memberPermissions: bigint | null

Inherited from:GateContextBase

memberRoleIds

The member's role ids without the everyone role, the shape a raw interaction payload contains. Empty outside a guild, or when the event doesn't carry the member's roles.

readonly memberRoleIds: readonly string[]

Inherited from:GateContextBase

user

Every repliable interaction contains a user.

readonly user: APIUser

userId

The id of the user who triggered it, or null on an event without a user.

readonly userId: string | null

Inherited from:DispatchOrigin

userLocale

The language that the user picked in Discord, or null on a gateway event because a discord.js User doesn't have one.

readonly userLocale: Locale | null

Inherited from:DispatchOrigin