Skip to content
Interfacegatewayv0.11.0

InteractionGateContext

The context that a gate gets on an interaction. It extends GuildPermissionsContext with the live interaction and the djs objects resolved from the gateway cache. Repliable is the interaction type the gate supports, inferred from the ctx annotation, so a gate reading button-specific fields is rejected on a slash handler. user is always present because interaction is the reply target. Use NonModalInteraction to exclude ModalSubmit when the gate needs a reliable caller member or channel.

interface InteractionGateContext<
    Repliable extends Repliables = Repliables
>
    extends GuildPermissionsContext, AppPermissionsContext
import type { ButtonInteraction } from 'discord.js';

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

Repliable

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

Repliable extends Repliables = Repliables

appGuildPermissions

The bot's base permission set from the transport's cache. It's 0n in a guild the bot isn't in. It's null when the guild is cached but the bot's member isn't.

readonly appGuildPermissions: bigint | null

Inherited from:GuildPermissionsContext

appPermissions

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

readonly appPermissions: bigint

Inherited from:AppPermissionsContext

core

The running framework, with the gateway's bot and bus.

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

guild

The guild that the interaction happened in, or null in a DM.

readonly guild: Guild | null

guildLocale

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

readonly guildLocale: Locale | null

Inherited from:DispatchOrigin

interaction

The interaction being handled, which is the reply target.

readonly interaction: Repliable

kind

The literal 'interaction'. Narrow on it before reading interaction.

readonly kind: 'interaction'

member

The invoking member from the cache, or null outside a guild or when uncached.

readonly member: GuildMember | null

memberGuildPermissions

The member's base permission set, roles only, matching djs GuildMember.permissions. Null when the member is unavailable.

readonly memberGuildPermissions: bigint | null

Inherited from:GuildPermissionsContext

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

The invoking user, always present on an interaction.

readonly user: User

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