Skip to content
Interfacecorev0.14.0

GateContextBase

The transport-agnostic gate context, the scalar identity of the acting user resolvable from any transport's payload. Every field except core is nullable since an event or DM may carry no guild or member. Each transport extends it with its own context. For example, the gateway adds the djs user/guild/member objects and the live interaction or event payload.

interface GateContextBase extends DispatchOrigin, DispatchMemberValues
// a gate reading only the base fields fits any handler on any transport
const NeedsGuild = defineGate('NeedsGuild', (ctx: GateContextBase) => {
    if (!ctx.guildId) throw new NotInGuild();
});

core

Gates read the config and the rate limiter through it.

readonly core: CoreBase

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

guildLocale

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

readonly guildLocale: Locale | null

Inherited from:DispatchOrigin

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

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[]

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