# InteractionGateContext

`interface` in `http` · v0.8.0

<https://docs.seedcord.org/packages/http/0.8.0/interfaces/interaction-gate-context>

The interaction gate context on the HTTP transport. It extends the scalar [`GateContextBase`](/packages/core/0.7.0/interfaces/gate-context-base) with the raw interaction payload and the user and member the payload carries. A gate reading button fields, inferred from its `ctx` annotation, is rejected on a slash handler.

The http transport delivers no role-derived permission sets, so `memberGuildPermissions` and `appGuildPermissions` are absent. A gate requiring `GuildPermissionsContext` (a permission gate with `in: 'guild'`) is a compile error on an http handler.

```ts
interface InteractionGateContext<
    Repliable extends Repliables = Repliables
> extends GateContextBase
```

## Examples

```ts
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
});
```

## Properties

### appPermissions

```ts
readonly appPermissions: bigint | null
```

The bot's permissions in the invoked channel, the wire `app_permissions` value. Null on gateway events.

### channelId

```ts
readonly channelId: string | null
```

The channel id, or null when the source carries none.

### core

```ts
readonly core: Core
```

### declaredRoute

```ts
readonly declaredRoute: string | null
```

The handler's own route, as `kind:route` (`slash:daily`, `button:confirm`). A handler registered on several reports the one this dispatch matched. Null when the handler declares none, which covers a plain event handler, the unhandled default, and a gate run outside a handler.

### dispatch

```ts
readonly dispatch: DispatchContext
```

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

### guildId

```ts
readonly guildId: string | null
```

The guild id, or null outside a guild.

### interaction

```ts
readonly interaction: Repliable
```

The raw interaction payload, which is the reply target.

### kind

```ts
readonly kind: 'interaction'
```

Narrow on this before reading `interaction`.

### member

```ts
readonly member: APIInteractionGuildMember | null
```

The invoking member, or null in a DM.

### memberPermissions

```ts
readonly memberPermissions: bigint | null
```

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.

### memberRoleIds

```ts
readonly memberRoleIds: readonly string[]
```

The member's role ids without the everyone role, the shape a raw interaction payload contains. Empty outside a guild or when the source contains none.

### user

```ts
readonly user: APIUser
```

Every repliable interaction contains a user.

### userId

```ts
readonly userId: string | null
```

The acting user's id, or null on an event that carries none.
