# Objects

> Every object the bot API and its gateway send, field by field, as Klang fills them in. Which fields are always there, which are only there sometimes, and which are always empty because Klang has nothing behind them.

## How to read the tables

The objects have the names and shapes of Discord’s API version 10, so libraries parse them as
they are. Each table lists every field Klang sends:

- **Always**: the field is in every object of that kind.
- **Sometimes**: the field is only there when it applies; the note says when.
- **Fixed**: the field is always there with the same value, because Klang doesn’t have what it
  describes. Don’t build on it: it may start to mean something later.

Fields of Discord’s objects that aren’t in a table are never sent by Klang.

## User

A person, a bot or the author of a webhook message.

| Field           | Type            | Present   | Notes                                                                                                                                                                                                             |
| --------------- | --------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`            | ID              | Always    |                                                                                                                                                                                                                   |
| `username`      | string          | Always    | The unique name. For a webhook, the name it posted with.                                                                                                                                                          |
| `discriminator` | string          | Always    | `"0"` for people and bots. `"0000"` for webhook authors.                                                                                                                                                          |
| `global_name`   | string or null  | Always    | The display name. `null` only for webhook authors.                                                                                                                                                                |
| `avatar`        | hash or null    | Always    | See [Images](https://docs.klang.gg/bots/libraries/#images).                                                                                                                                                                            |
| `banner`        | hash or null    | Sometimes | People and bots. Not on webhook authors or the deleted user.                                                                                                                                                      |
| `accent_color`  | integer or null | Sometimes | The profile’s colour, as for `banner`.                                                                                                                                                                            |
| `public_flags`  | integer         | Always    | `STAFF` (`1 << 0`) for Klang’s team, `PREMIUM_EARLY_SUPPORTER` (`1 << 9`) for early supporters and `VERIFIED_BOT` (`1 << 16`) for [verified bots](https://docs.klang.gg/bots/getting-started/#verify-your-bot). `0` for everyone else. |
| `bot`           | boolean         | Sometimes | `true` on bots and webhook authors. Left out for people.                                                                                                                                                          |
| `flags`         | integer         | Sometimes | Only on the bot’s own user (`GET /users/@me`, `READY`, `USER_UPDATE`): the same as `public_flags`.                                                                                                                |
| `verified`      | boolean         | Sometimes | Only on the bot’s own user. Fixed: `true`.                                                                                                                                                                        |
| `mfa_enabled`   | boolean         | Sometimes | Only on the bot’s own user. Fixed: `false`.                                                                                                                                                                       |
| `email`         | null            | Sometimes | Only on the bot’s own user. Fixed: `null`.                                                                                                                                                                        |
| `locale`        | string          | Sometimes | Only on the bot’s own user. Fixed: `"en-US"`.                                                                                                                                                                     |

When an account is deleted, its messages stay and their author is one fixed user: `id`
`1323802873036800000`, `username` `deleted_user`, `global_name` `Deleted user`, no avatar.

```json
{
  "id": "1571350327143452672",
  "username": "leo",
  "discriminator": "0",
  "global_name": "Leo",
  "avatar": null,
  "banner": null,
  "accent_color": null,
  "public_flags": 0
}
```

## Application

The bot’s app, from `GET /applications/@me`. Its `id` is also the bot’s user ID.

| Field                       | Type           | Present | Notes                                                                                                                                                                                                                                                                                          |
| --------------------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                        | ID             | Always  |                                                                                                                                                                                                                                                                                                |
| `name`                      | string         | Always  |                                                                                                                                                                                                                                                                                                |
| `icon`                      | hash or null   | Always  | The app’s icon, which is also the bot’s avatar.                                                                                                                                                                                                                                                |
| `description`               | string         | Always  | Up to 400 characters, set in the portal.                                                                                                                                                                                                                                                       |
| `bot`                       | user           | Always  | The bot’s user.                                                                                                                                                                                                                                                                                |
| `owner`                     | user           | Always  | The developer. If their account is gone, the bot itself.                                                                                                                                                                                                                                       |
| `flags`                     | integer        | Always  | Only the privileged intents switched on: `GATEWAY_GUILD_MEMBERS_LIMITED` (`1 << 15`) and `GATEWAY_MESSAGE_CONTENT_LIMITED` (`1 << 19`). After a review by Klang’s team, the bits without `_LIMITED` (`1 << 14`, `1 << 18`). Past 100 servers, only those: the `_LIMITED` ones go at the 101st. |
| `flags_new`                 | string         | Always  | `flags`, as a string.                                                                                                                                                                                                                                                                          |
| `approximate_guild_count`   | integer        | Always  | How many servers the bot is in.                                                                                                                                                                                                                                                                |
| `summary`                   | string         | Fixed   | `""`.                                                                                                                                                                                                                                                                                          |
| `bot_public`                | boolean        | Fixed   | `false`: during the beta only accounts on the list add bots.                                                                                                                                                                                                                                   |
| `bot_require_code_grant`    | boolean        | Fixed   | `false`.                                                                                                                                                                                                                                                                                       |
| `verify_key`                | string         | Always  | The public key that signs [HTTP interactions](https://docs.klang.gg/bots/http-interactions/), in hex, as the portal shows it. Klang makes the key the first time it’s needed, so it’s never empty here.                                                                                                             |
| `team`                      | null           | Fixed   | `null`.                                                                                                                                                                                                                                                                                        |
| `redirect_uris`             | array          | Fixed   | `[]`.                                                                                                                                                                                                                                                                                          |
| `interactions_endpoint_url` | string or null | Always  | The [interactions endpoint URL](https://docs.klang.gg/bots/http-interactions/), or `null` when interactions go through the gateway. Set it in the portal or with [`PATCH /applications/@me`](https://docs.klang.gg/bots/reference/users/#set-the-interactions-url).                                                                      |

## Server

A server (a guild, in the API’s words): from `GET /guilds/{guild.id}`, `GUILD_CREATE` and
`GUILD_UPDATE`. There’s an example in [Servers](https://docs.klang.gg/bots/reference/guilds/#a-server).

| Field                           | Type              | Present   | Notes                                                                                                                                                                                                           |
| ------------------------------- | ----------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                            | ID                | Always    |                                                                                                                                                                                                                 |
| `name`                          | string            | Always    |                                                                                                                                                                                                                 |
| `icon`                          | hash or null      | Always    | Starts with `a_` when it moves.                                                                                                                                                                                 |
| `banner`                        | hash or null      | Always    | As `icon`.                                                                                                                                                                                                      |
| `owner_id`                      | ID                | Always    | If the owner’s account is gone, the deleted user’s ID.                                                                                                                                                          |
| `verification_level`            | integer           | Always    | `0` none; `1` a registered account, or a confirmed email; `2` an account older than 10 minutes; `3` a member for more than 10 minutes. Never `4`.                                                               |
| `roles`                         | array of roles    | Always    | Every role, `@everyone` included.                                                                                                                                                                               |
| `emojis`                        | array of emojis   | Always    |                                                                                                                                                                                                                 |
| `stickers`                      | array of stickers | Always    |                                                                                                                                                                                                                 |
| `features`                      | array of strings  | Always    | Only true ones: `PIN_PERMISSION_MIGRATION_COMPLETE` (always: pinning has its own permission), `BANNER`, `ANIMATED_BANNER`, `ANIMATED_ICON`, `INVITES_DISABLED` (new members paused) and `RAID_ALERTS_DISABLED`. |
| `system_channel_id`             | ID or null        | Always    | Where welcome messages go.                                                                                                                                                                                      |
| `system_channel_flags`          | integer           | Always    | `1` when welcome messages are off, `0` when they’re on.                                                                                                                                                         |
| `premium_tier`                  | integer           | Always    | The server’s Klang plan: `0` free, `1` or `2` paid.                                                                                                                                                             |
| `approximate_member_count`      | integer           | Always    |                                                                                                                                                                                                                 |
| `incidents_data`                | object or null    | Always    | While new members are paused: `invites_disabled_until` (a date, or `null` until someone resumes them) and `dms_disabled_until: null`. Otherwise `null`.                                                         |
| `approximate_presence_count`    | integer           | Sometimes | With `with_counts=true`: people online now.                                                                                                                                                                     |
| `splash`, `discovery_splash`    | null              | Fixed     | `null`.                                                                                                                                                                                                         |
| `description`                   | null              | Fixed     | `null`.                                                                                                                                                                                                         |
| `afk_channel_id`                | null              | Fixed     | `null`.                                                                                                                                                                                                         |
| `afk_timeout`                   | integer           | Fixed     | `300`.                                                                                                                                                                                                          |
| `widget_enabled`                | boolean           | Fixed     | `false`.                                                                                                                                                                                                        |
| `widget_channel_id`             | null              | Fixed     | `null`.                                                                                                                                                                                                         |
| `default_message_notifications` | integer           | Fixed     | `1`.                                                                                                                                                                                                            |
| `explicit_content_filter`       | integer           | Fixed     | `0`.                                                                                                                                                                                                            |
| `mfa_level`                     | integer           | Fixed     | `0`.                                                                                                                                                                                                            |
| `application_id`                | null              | Fixed     | `null`.                                                                                                                                                                                                         |
| `rules_channel_id`              | null              | Fixed     | `null`.                                                                                                                                                                                                         |
| `max_presences`                 | null              | Fixed     | `null`.                                                                                                                                                                                                         |
| `max_members`                   | integer           | Fixed     | `500000`.                                                                                                                                                                                                       |
| `vanity_url_code`               | null              | Fixed     | `null`.                                                                                                                                                                                                         |
| `premium_subscription_count`    | integer           | Fixed     | `0`.                                                                                                                                                                                                            |
| `preferred_locale`              | string            | Fixed     | `"en-US"`.                                                                                                                                                                                                      |
| `public_updates_channel_id`     | null              | Fixed     | `null`.                                                                                                                                                                                                         |
| `max_video_channel_users`       | integer           | Fixed     | `25`.                                                                                                                                                                                                           |
| `max_stage_video_channel_users` | integer           | Fixed     | `0`.                                                                                                                                                                                                            |
| `nsfw_level`                    | integer           | Fixed     | `0`.                                                                                                                                                                                                            |
| `premium_progress_bar_enabled`  | boolean           | Fixed     | `false`.                                                                                                                                                                                                        |
| `hub_type`                      | null              | Fixed     | `null`.                                                                                                                                                                                                         |
| `safety_alerts_channel_id`      | null              | Fixed     | `null`.                                                                                                                                                                                                         |

`GUILD_CREATE` adds the fields of [the server as the bot joins it](https://docs.klang.gg/bots/reference/gateway-events/#guild_create).

**The short form**, in `GET /users/@me/guilds`, has `id`, `name`, `icon`, `banner`, `owner`
(always `false`), `permissions`, `features` and, with `with_counts=true`,
`approximate_member_count` and `approximate_presence_count`.

**An unavailable server**, in `READY` and `GUILD_DELETE`, has `id` and `unavailable`.

## Role

| Field           | Type    | Present   | Notes                                                                                 |
| --------------- | ------- | --------- | ------------------------------------------------------------------------------------- |
| `id`            | ID      | Always    | `@everyone`’s is the server’s ID.                                                     |
| `name`          | string  | Always    |                                                                                       |
| `color`         | integer | Always    | RGB. `0` is no colour.                                                                |
| `colors`        | object  | Always    | `primary_color` is `color`; `secondary_color` and `tertiary_color` are always `null`. |
| `hoist`         | boolean | Always    | Shown apart in the member list.                                                       |
| `position`      | integer | Always    | `@everyone` is `0`; higher is above.                                                  |
| `permissions`   | string  | Always    | Discord’s bits. See [Permissions](https://docs.klang.gg/bots/differences/#permissions).                    |
| `managed`       | boolean | Always    | `true` only for a bot’s own role, which comes and goes with the bot.                  |
| `mentionable`   | boolean | Always    |                                                                                       |
| `tags`          | object  | Sometimes | Only on a bot’s role: `{ "bot_id": "…" }`.                                            |
| `icon`          | null    | Fixed     | `null`.                                                                               |
| `unicode_emoji` | null    | Fixed     | `null`.                                                                               |
| `flags`         | integer | Fixed     | `0`.                                                                                  |

## Emoji

A server’s custom emoji, in a server’s `emojis`. In reactions, a partial emoji: see
[Reaction](https://docs.klang.gg/bots/reference/objects/#reaction).

| Field            | Type    | Present | Notes                        |
| ---------------- | ------- | ------- | ---------------------------- |
| `id`             | ID      | Always  |                              |
| `name`           | string  | Always  |                              |
| `animated`       | boolean | Always  |                              |
| `roles`          | array   | Fixed   | `[]`: any member can use it. |
| `require_colons` | boolean | Fixed   | `true`.                      |
| `managed`        | boolean | Fixed   | `false`.                     |
| `available`      | boolean | Fixed   | `true`.                      |

## Sticker

A server’s sticker, in a server’s `stickers`.

| Field         | Type           | Present | Notes                                                                                                                                    |
| ------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `id`          | ID             | Always  |                                                                                                                                          |
| `name`        | string         | Always  |                                                                                                                                          |
| `tags`        | string         | Always  | The emoji chosen for it, which suggests it while typing.                                                                                 |
| `format_type` | integer        | Always  | `1` (PNG) for a still sticker, `4` (GIF) for one that moves.                                                                             |
| `guild_id`    | ID             | Always  |                                                                                                                                          |
| `description` | string or null | Always  | From the sticker routes, its description, or `null` without one. In a server’s `stickers` and in `GUILD_STICKERS_UPDATE`, always `null`. |
| `type`        | integer        | Fixed   | `2`: a server’s sticker.                                                                                                                 |
| `available`   | boolean        | Fixed   | `true`.                                                                                                                                  |

`format_type` says whether the sticker moves, not the file’s format: Klang keeps PNG, APNG, GIF
and WebP stickers.

## Sticker item

The sticker of a message, in `sticker_items`: `id`, `name` and `format_type`, as in
[Sticker](https://docs.klang.gg/bots/reference/objects/#sticker).

## Member

A person or bot in a server, from the member routes, `GUILD_CREATE` and `GUILD_MEMBER_*`.

| Field                          | Type           | Present   | Notes                                                                                                    |
| ------------------------------ | -------------- | --------- | -------------------------------------------------------------------------------------------------------- |
| `user`                         | user           | Sometimes | Left out where the user is next to it: a message’s `member` and a mention’s `member`.                    |
| `nick`                         | string or null | Always    | The nickname in this server.                                                                             |
| `roles`                        | array of IDs   | Always    | Without `@everyone`.                                                                                     |
| `joined_at`                    | date           | Always    |                                                                                                          |
| `communication_disabled_until` | date or null   | Always    | When their timeout ends, while they’re timed out.                                                        |
| `flags`                        | integer        | Always    | `BYPASSES_VERIFICATION` (`1 << 2`) on bots: the verification level doesn’t apply to them. `0` on people. |
| `avatar`, `banner`             | null           | Fixed     | `null`: Klang has no avatars per server.                                                                 |
| `premium_since`                | null           | Fixed     | `null`.                                                                                                  |
| `deaf`, `mute`                 | boolean        | Fixed     | `false` for now.                                                                                         |
| `pending`                      | boolean        | Fixed     | `false`.                                                                                                 |

## Server channel

A text channel (`type` `0`), voice channel (`2`) or category (`4`). Voice channels in Klang
have their own chat, so they carry `last_message_id` and `rate_limit_per_user` too.

| Field                           | Type           | Present     | Notes                                                               |
| ------------------------------- | -------------- | ----------- | ------------------------------------------------------------------- |
| `id`                            | ID             | Always      |                                                                     |
| `type`                          | integer        | Always      | `0`, `2` or `4`.                                                    |
| `guild_id`                      | ID             | Always      |                                                                     |
| `name`                          | string         | Always      |                                                                     |
| `position`                      | integer        | Always      |                                                                     |
| `permission_overwrites`         | array          | Always      | [Overwrites](https://docs.klang.gg/bots/reference/objects/#permission-overwrite), with the category’s merged in. |
| `nsfw`                          | boolean        | Always      | Age-restricted.                                                     |
| `parent_id`                     | ID or null     | Always      | The category. Always `null` on a category.                          |
| `last_message_id`               | ID or null     | Text, voice | The newest message. It may point to a message that was deleted.     |
| `rate_limit_per_user`           | integer        | Text, voice | Slow mode, in seconds. `0` is off.                                  |
| `topic`                         | string or null | Text        |                                                                     |
| `user_limit`                    | integer        | Voice       | `0` is no limit.                                                    |
| `flags`                         | integer        | Fixed       | `0`.                                                                |
| `default_auto_archive_duration` | integer        | Fixed       | Text: `10080`.                                                      |
| `bitrate`                       | integer        | Fixed       | Voice: `64000`. Klang picks the quality by plan.                    |
| `rtc_region`                    | null           | Fixed       | Voice: `null`.                                                      |

## Permission overwrite

| Field   | Type    | Notes                                 |
| ------- | ------- | ------------------------------------- |
| `id`    | ID      | The role or the member it applies to. |
| `type`  | integer | `0` a role, `1` a member.             |
| `allow` | string  | Discord’s bits it allows.             |
| `deny`  | string  | Discord’s bits it denies.             |

All four are always there.

## Thread

A public thread in a text channel. Klang has no private threads and no forums.

| Field                 | Type       | Present | Notes                                                                                        |
| --------------------- | ---------- | ------- | -------------------------------------------------------------------------------------------- |
| `id`                  | ID         | Always  |                                                                                              |
| `type`                | integer    | Always  | Always `11`.                                                                                 |
| `guild_id`            | ID         | Always  |                                                                                              |
| `parent_id`           | ID         | Always  | The text channel it’s in.                                                                    |
| `name`                | string     | Always  |                                                                                              |
| `last_message_id`     | ID or null | Always  | In a thread with no messages yet, it doesn’t point to a message.                             |
| `rate_limit_per_user` | integer    | Always  | Its channel’s slow mode, which applies in it.                                                |
| `message_count`       | integer    | Always  |                                                                                              |
| `total_message_sent`  | integer    | Always  | The same as `message_count`.                                                                 |
| `thread_metadata`     | object     | Always  | See below.                                                                                   |
| `owner_id`            | ID         | Always  | Who opened it. The deleted user’s ID when that account is gone, and in a message’s `thread`. |
| `member_count`        | integer    | Fixed   | `0`. Klang doesn’t count a thread’s members yet.                                             |
| `flags`               | integer    | Fixed   | `0`.                                                                                         |

`thread_metadata`:

| Field                   | Type    | Notes                                                               |
| ----------------------- | ------- | ------------------------------------------------------------------- |
| `archived`              | boolean | `true` after 7 days without messages. Writing in it brings it back. |
| `auto_archive_duration` | integer | Always `10080`: 7 days.                                             |
| `archive_timestamp`     | date    | When it went quiet, if it’s archived; when it was created, if not.  |
| `locked`                | boolean | Only people who can manage threads write in it.                     |
| `create_timestamp`      | date    |                                                                     |

## Direct message channel

A direct message between the bot and one person.

| Field             | Type           | Present | Notes                            |
| ----------------- | -------------- | ------- | -------------------------------- |
| `id`              | ID             | Always  | The channel to send messages to. |
| `type`            | integer        | Always  | Always `1`.                      |
| `recipients`      | array of users | Always  | The person, never the bot.       |
| `last_message_id` | ID or null     | Always  |                                  |
| `name`            | null           | Fixed   | `null`.                          |
| `flags`           | integer        | Fixed   | `0`.                             |

## Message

From the message routes, `MESSAGE_CREATE` and `MESSAGE_UPDATE`. There are examples in
[Messages](https://docs.klang.gg/bots/reference/messages/).

| Field                  | Type                                          | Present   | Notes                                                                                                                                                                                                                                                                      |
| ---------------------- | --------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                   | ID                                            | Always    |                                                                                                                                                                                                                                                                            |
| `channel_id`           | ID                                            | Always    |                                                                                                                                                                                                                                                                            |
| `type`                 | integer                                       | Always    | See [Message types](https://docs.klang.gg/bots/reference/objects/#message-types).                                                                                                                                                                                                                                       |
| `author`               | user                                          | Always    | A person, a bot, a webhook author or the deleted user.                                                                                                                                                                                                                     |
| `content`              | string                                        | Always    | IDs in mentions are the ones bots use. Empty without `MESSAGE_CONTENT`, with the exceptions in [Messages](https://docs.klang.gg/bots/reference/messages/#content-and-the-message_content-intent).                                                                                               |
| `timestamp`            | date                                          | Always    |                                                                                                                                                                                                                                                                            |
| `edited_timestamp`     | date or null                                  | Always    |                                                                                                                                                                                                                                                                            |
| `mention_everyone`     | boolean                                       | Always    | Whether `@everyone` notified. Klang has no `@here`.                                                                                                                                                                                                                        |
| `mentions`             | array of users                                | Always    | The people it notified. In gateway events, each can carry its `member`.                                                                                                                                                                                                    |
| `mention_roles`        | array of IDs                                  | Always    | The roles it notified.                                                                                                                                                                                                                                                     |
| `attachments`          | array of [attachments](https://docs.klang.gg/bots/reference/objects/#attachment)           | Always    |                                                                                                                                                                                                                                                                            |
| `embeds`               | array of [embeds](https://docs.klang.gg/bots/reference/objects/#embed)                     | Always    |                                                                                                                                                                                                                                                                            |
| `pinned`               | boolean                                       | Always    |                                                                                                                                                                                                                                                                            |
| `flags`                | integer                                       | Always    | `SUPPRESS_EMBEDS` (`1 << 2`): no link previews. `HAS_THREAD` (`1 << 5`): a thread started from it. `EPHEMERAL` (`1 << 6`): an ephemeral answer to an interaction. `IS_COMPONENTS_V2` (`1 << 15`): the message is made of layout components, without `content` or `embeds`. |
| `reactions`            | array of [reactions](https://docs.klang.gg/bots/reference/objects/#reaction)               | Sometimes | When someone reacted.                                                                                                                                                                                                                                                      |
| `nonce`                | string                                        | Sometimes | On the answer to sending it and in its `MESSAGE_CREATE`, if the sender gave one.                                                                                                                                                                                           |
| `webhook_id`           | ID                                            | Sometimes | Posted by a webhook. On an answer to an interaction, the app’s ID.                                                                                                                                                                                                         |
| `application_id`       | ID                                            | Sometimes | An answer to an interaction: the app that answered.                                                                                                                                                                                                                        |
| `interaction_metadata` | [interaction metadata](https://docs.klang.gg/bots/reference/objects/#interaction-metadata) | Sometimes | An answer to an interaction: which interaction, and who used the command.                                                                                                                                                                                                  |
| `interaction`          | object                                        | Sometimes | The older form of `interaction_metadata`, which libraries still read: `id`, `type`, `name` (the command, or the `custom_id` of the component or the modal) and `user`.                                                                                                     |
| `message_reference`    | object                                        | Sometimes | Replies, pin notices and new thread notices. See below.                                                                                                                                                                                                                    |
| `referenced_message`   | message or null                               | Sometimes | Only on replies (type `19`): the message it answers, without its own `referenced_message`, or `null` if it’s gone or not at hand.                                                                                                                                          |
| `sticker_items`        | array                                         | Sometimes | One [sticker item](https://docs.klang.gg/bots/reference/objects/#sticker-item).                                                                                                                                                                                                                                         |
| `poll`                 | [poll](https://docs.klang.gg/bots/reference/objects/#poll)                                 | Sometimes | A poll.                                                                                                                                                                                                                                                                    |
| `call`                 | object                                        | Sometimes | A call notice in a direct message: `participants` (IDs) and `ended_timestamp`.                                                                                                                                                                                             |
| `thread`               | [thread](https://docs.klang.gg/bots/reference/objects/#thread)                             | Sometimes | The thread started from this message.                                                                                                                                                                                                                                      |
| `tts`                  | boolean                                       | Fixed     | `false`.                                                                                                                                                                                                                                                                   |
| `components`           | array                                         | Always    | Its [components](https://docs.klang.gg/bots/reference/components/): buttons and select menus, or the layout of a message with `IS_COMPONENTS_V2`. `[]` when it has none.                                                                                                                        |

**In gateway events**, `MESSAGE_CREATE` and `MESSAGE_UPDATE` add:

| Field          | Type    | Present   | Notes                                                                                                                         |
| -------------- | ------- | --------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `channel_type` | integer | Always    | `0` text, `2` voice, `11` thread, `1` direct message.                                                                         |
| `guild_id`     | ID      | Sometimes | In servers. Not in direct messages.                                                                                           |
| `member`       | member  | Sometimes | The author’s member, without `user`, in servers. Webhook messages and members the gateway doesn’t have at hand go without it. |

**`message_reference`** has `type` (always `0`), `channel_id`, `guild_id` (not in direct
messages) and `message_id`. On a reply it points to the message answered; on a pin notice, to
the pinned message; on a new thread notice, to the thread, as `channel_id`, without
`message_id`.

### Message types

| `type` | What it is in Klang                                                                                                                       |
| ------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `0`    | A message. Also Klang’s role panels, ticket panels and ticket updates, with their text, and a bot’s answers to its components and modals. |
| `3`    | A call in a direct message.                                                                                                               |
| `6`    | Someone pinned a message.                                                                                                                 |
| `7`    | Someone joined the server.                                                                                                                |
| `18`   | Someone opened a thread. `content` is its name.                                                                                           |
| `19`   | A reply.                                                                                                                                  |
| `20`   | An answer to a slash command.                                                                                                             |
| `23`   | An answer to a user or message command.                                                                                                   |
| `24`   | An AutoMod alert, with an `auto_moderation_message` embed.                                                                                |
| `46`   | A poll ended, with a `poll_result` embed.                                                                                                 |

## Embed

**The embeds a bot or a webhook writes** have `type` `rich` and the fields that were sent and
kept: `title`, `description`, `url`, `color`, `timestamp`, `author` (`name`, `url`, `icon_url`,
`proxy_icon_url`), `footer` (`text`, `icon_url`, `proxy_icon_url`), `image` (`url`, `proxy_url`),
`thumbnail` (`url`, `proxy_url`) and `fields` (`name`, `value`, `inline`). Empty ones are left
out. Image and icon addresses only stay if they’re `https` on a public host and not on Discord’s
image servers, and links only if they’re `http` or `https`. [Embeds](https://docs.klang.gg/webhooks/embeds/) has
every limit.

`proxy_url` and `proxy_icon_url` are the same image through Klang’s image proxy
(`https://img.klangcdn.com/…`), the address the app loads it from. Link previews’ images and
thumbnails carry `proxy_url` too.

**Link previews** that Klang makes for links in the text come after them:

| `type`  | Fields                                                                                                                                              |
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `link`  | `url`, and when the page has them: `title`, `description`, `color`, `provider.name`, `author` and `image` or `thumbnail` with `width` and `height`. |
| `image` | `url` and `thumbnail`.                                                                                                                              |
| `video` | `url`, `title`, `thumbnail`, `provider` (`YouTube` or `Vimeo`, with its `url`) and `video.url`, the player.                                         |

`SUPPRESS_EMBEDS` removes the previews and keeps the author’s embeds.

**Notices** carry one embed of their own, made of named fields:

- `poll_result` (message type `46`): `poll_question_text`, `victor_answer_votes`,
  `total_votes` and, when one answer won alone, `victor_answer_id`, `victor_answer_text` and
  its emoji: `victor_answer_emoji_id`, `victor_answer_emoji_animated` (custom emojis) and
  `victor_answer_emoji_name`.
- `auto_moderation_message` (message type `24`): `rule_name`, `channel_id` and, when there’s
  one, `keyword_matched_content`.

## Attachment

| Field             | Type    | Present   | Notes                                                                                                                           |
| ----------------- | ------- | --------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `id`              | ID      | Always    |                                                                                                                                 |
| `filename`        | string  | Always    |                                                                                                                                 |
| `content_type`    | string  | Always    | The file’s real type, checked by Klang when it was uploaded.                                                                    |
| `size`            | integer | Always    | In bytes.                                                                                                                       |
| `url`             | string  | Always    | A public address. It doesn’t expire, except for `ephemeral` files.                                                              |
| `proxy_url`       | string  | Always    | The same as `url`.                                                                                                              |
| `width`, `height` | integer | Sometimes | Images and videos.                                                                                                              |
| `duration_secs`   | number  | Sometimes | Audio and video.                                                                                                                |
| `description`     | string  | Sometimes | Its alt text, when whoever sent it gave one (up to 1,024 characters).                                                           |
| `ephemeral`       | boolean | Sometimes | `true` on the files of a modal’s file upload: they belong to no message, and Klang deletes them a day after they were uploaded. |

## Reaction

| Field           | Type    | Notes                                                                                             |
| --------------- | ------- | ------------------------------------------------------------------------------------------------- |
| `emoji`         | object  | A Unicode emoji as `{ "id": null, "name": "👋" }`; a custom one with `id`, `name` and `animated`. |
| `count`         | integer | How many reacted with it.                                                                         |
| `count_details` | object  | `normal` is `count`; `burst` is always `0`.                                                       |
| `me`            | boolean | Whether the bot reacted with it.                                                                  |
| `me_burst`      | boolean | Always `false`: Klang has no super reactions.                                                     |
| `burst_colors`  | array   | Always `[]`.                                                                                      |

```json
{
  "emoji": { "id": "1571350334105997312", "name": "anchor", "animated": false },
  "count": 1,
  "count_details": { "burst": 0, "normal": 1 },
  "me": true,
  "me_burst": false,
  "burst_colors": []
}
```

## Poll

A message’s poll. Bots read polls and [send them](https://docs.klang.gg/bots/reference/server-content/#send-a-poll); they don’t vote.

| Field               | Type    | Notes                                                                                                                                                  |
| ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `question`          | object  | `{ "text": "…" }`.                                                                                                                                     |
| `answers`           | array   | Each with `answer_id` (from `1`) and `poll_media`: `text` and, if it has one, `emoji`.                                                                 |
| `expiry`            | date    | When it closes.                                                                                                                                        |
| `allow_multiselect` | boolean |                                                                                                                                                        |
| `layout_type`       | integer | Always `1`.                                                                                                                                            |
| `results`           | object  | `is_finalized` (`true` once closed) and `answer_counts`: `id`, `count` and `me_voted` for each answer with votes. Answers without votes aren’t listed. |

```json
{
  "question": { "text": "Boat trip on Saturday?" },
  "answers": [
    { "answer_id": 1, "poll_media": { "text": "Yes", "emoji": { "id": null, "name": "⛵" } } },
    { "answer_id": 2, "poll_media": { "text": "No" } }
  ],
  "expiry": "2026-11-16T02:25:15.153Z",
  "allow_multiselect": false,
  "layout_type": 1,
  "results": {
    "is_finalized": false,
    "answer_counts": [{ "id": 1, "count": 1, "me_voted": false }]
  }
}
```

## Application command

A command your app registered, from the [command routes](https://docs.klang.gg/bots/reference/commands/).

| Field                        | Type                                            | Present   | Notes                                                                                 |
| ---------------------------- | ----------------------------------------------- | --------- | ------------------------------------------------------------------------------------- |
| `id`                         | ID                                              | Always    |                                                                                       |
| `type`                       | integer                                         | Always    | `1` slash, `2` user, `3` message.                                                     |
| `application_id`             | ID                                              | Always    |                                                                                       |
| `guild_id`                   | ID                                              | Sometimes | Only on a server’s commands.                                                          |
| `name`                       | string                                          | Always    |                                                                                       |
| `name_localizations`         | object or null                                  | Sometimes | Left out of the lists unless they ask `with_localizations=true`.                      |
| `name_localized`             | string                                          | Sometimes | In the lists, when the request sends `X-Discord-Locale` without `with_localizations`. |
| `description`                | string                                          | Always    | `""` for user and message commands.                                                   |
| `description_localizations`  | object or null                                  | Sometimes | As `name_localizations`.                                                              |
| `description_localized`      | string                                          | Sometimes | As `name_localized`.                                                                  |
| `options`                    | array of [options](https://docs.klang.gg/bots/reference/objects/#application-command-option) | Sometimes | Slash commands, even when empty.                                                      |
| `default_member_permissions` | string or null                                  | Always    | Discord’s bits, or `null` for everyone.                                               |
| `dm_permission`              | boolean                                         | Always    | Whether `contexts` includes the bot’s direct messages.                                |
| `nsfw`                       | boolean                                         | Always    |                                                                                       |
| `contexts`                   | array of integers or null                       | Always    | As registered. `null` means servers and the bot’s direct messages.                    |
| `version`                    | ID                                              | Always    | Changes every time the command changes.                                               |
| `integration_types`          | array of integers                               | Fixed     | `[0]`: Klang only installs bots in servers.                                           |

There’s an example in [Create a command](https://docs.klang.gg/bots/reference/commands/#create-a-command).

## Application command option

| Field                       | Type              | Present   | Notes                                                         |
| --------------------------- | ----------------- | --------- | ------------------------------------------------------------- |
| `type`                      | integer           | Always    | From `1` (subcommand) to `11` (attachment).                   |
| `name`                      | string            | Always    |                                                               |
| `name_localizations`        | object or null    | Sometimes | As in the command.                                            |
| `name_localized`            | string            | Sometimes | As in the command.                                            |
| `description`               | string            | Always    |                                                               |
| `description_localizations` | object or null    | Sometimes | As in the command.                                            |
| `description_localized`     | string            | Sometimes | As in the command.                                            |
| `required`                  | boolean           | Sometimes | Only when `true`.                                             |
| `choices`                   | array             | Sometimes | `name`, `name_localizations` (as in the command) and `value`. |
| `options`                   | array             | Sometimes | A subcommand’s options, or a group’s subcommands.             |
| `channel_types`             | array of integers | Sometimes |                                                               |
| `min_value`, `max_value`    | number            | Sometimes |                                                               |
| `min_length`, `max_length`  | integer           | Sometimes |                                                               |
| `autocomplete`              | boolean           | Sometimes | Only when `true`.                                             |

Only the fields that were registered come back. Their rules are in
[Options](https://docs.klang.gg/bots/reference/commands/#options).

## Command permissions

Who can use an app’s commands in a server, from
[Command permissions](https://docs.klang.gg/bots/reference/commands/#command-permissions).

| Field            | Type  | Notes                                                                      |
| ---------------- | ----- | -------------------------------------------------------------------------- |
| `id`             | ID    | The command, or the app’s ID for the rules of all its commands.            |
| `application_id` | ID    |                                                                            |
| `guild_id`       | ID    |                                                                            |
| `permissions`    | array | Each with `id`, `type` (`1` role, `2` user, `3` channel) and `permission`. |

In `permissions`, the server’s ID is `@everyone` and the server’s ID minus one is every channel.
Klang’s managers set rules by role and by channel; rules for one person (`2`) are read, but can’t
be set in Klang yet.

## Interaction

What your bot gets when someone uses one of its commands: by the gateway, in
[`INTERACTION_CREATE`](https://docs.klang.gg/bots/reference/gateway-events/#interaction_create), or as the body of a
request to its [interactions endpoint URL](https://docs.klang.gg/bots/http-interactions/). It’s the same object either
way.

| Field                            | Type                                  | Present   | Notes                                                                                                                                                           |
| -------------------------------- | ------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                             | ID                                    | Always    |                                                                                                                                                                 |
| `application_id`                 | ID                                    | Always    |                                                                                                                                                                 |
| `type`                           | integer                               | Always    | `2` a command, `3` a component (a button or a select menu), `4` an autocomplete, `5` a submitted modal. `1` (`PING`) only reaches an interactions endpoint URL. |
| `data`                           | [interaction data](https://docs.klang.gg/bots/reference/objects/#interaction-data) | Always    |                                                                                                                                                                 |
| `token`                          | string                                | Always    | 96 characters. Answers this interaction for 15 minutes. Keep it to yourself.                                                                                    |
| `channel`                        | object                                | Always    | A partial channel, with `permissions`: the person’s permissions there.                                                                                          |
| `channel_id`                     | ID                                    | Always    |                                                                                                                                                                 |
| `app_permissions`                | string                                | Always    | The bot’s permissions in the channel.                                                                                                                           |
| `locale`                         | string                                | Always    | The person’s language, as a Discord locale: `en-US`, `es-ES`, `pt-BR`, `fr`, `de`, `it`, `ru`, `ja`, `tr` or `pl`.                                              |
| `context`                        | integer                               | Always    | `0` a server, `1` the bot’s direct messages.                                                                                                                    |
| `authorizing_integration_owners` | object                                | Always    | `{ "0": "<the server’s ID>" }`; `{ "0": "0" }` in direct messages.                                                                                              |
| `guild_id`                       | ID                                    | Sometimes | In a server.                                                                                                                                                    |
| `guild`                          | object                                | Sometimes | In a server: `id`, `locale` (`en-US`) and `features` (`[]`).                                                                                                    |
| `member`                         | member                                | Sometimes | In a server: who used it, with `user` and `permissions` in the channel.                                                                                         |
| `user`                           | user                                  | Sometimes | In direct messages: who used it.                                                                                                                                |
| `message`                        | [message](https://docs.klang.gg/bots/reference/objects/#message)                   | Sometimes | A component’s interaction, and a modal a component opened: the message of that component, always with its content.                                              |
| `version`                        | integer                               | Fixed     | `1`.                                                                                                                                                            |
| `guild_locale`                   | string                                | Fixed     | In a server: `en-US`. Klang’s servers have no language of their own.                                                                                            |
| `entitlements`                   | array                                 | Fixed     | `[]`: Klang has no paid apps.                                                                                                                                   |
| `attachment_size_limit`          | integer                               | Fixed     | `26214400` (25 MB).                                                                                                                                             |

There’s a full example in [`INTERACTION_CREATE`](https://docs.klang.gg/bots/reference/gateway-events/#interaction_create).

### Interaction data

Its fields depend on the interaction’s `type`. For a command or an autocomplete (`2` and `4`):

| Field       | Type    | Present   | Notes                                                  |
| ----------- | ------- | --------- | ------------------------------------------------------ |
| `id`        | ID      | Always    | The command’s ID.                                      |
| `name`      | string  | Always    | The command’s name as registered, never a translation. |
| `type`      | integer | Always    | The command’s type: `1`, `2` or `3`.                   |
| `guild_id`  | ID      | Sometimes | When it’s a server’s command.                          |
| `options`   | array   | Sometimes | Slash commands with values. See below.                 |
| `target_id` | ID      | Sometimes | User and message commands: the person or the message.  |
| `resolved`  | object  | Sometimes | What the options or the target name. See below.        |

Each item of `options` has the option’s `name` and `type` and, for a value, `value`: text, a
number, a boolean, or an ID for users, channels, roles and mentionables. A subcommand or a group
carries its own `options` instead. In an autocomplete, the option being typed has
`focused: true`, and its `value` is the text typed so far, unchecked.

`resolved` has a map per kind, keyed by ID, with only what was named:

| Key        | Holds                                                                                                         |
| ---------- | ------------------------------------------------------------------------------------------------------------- |
| `users`    | [Users](https://docs.klang.gg/bots/reference/objects/#user).                                                                                               |
| `members`  | Their [members](https://docs.klang.gg/bots/reference/objects/#member) in the server, without `user`, `deaf` and `mute`, with `permissions` in the channel. |
| `roles`    | [Roles](https://docs.klang.gg/bots/reference/objects/#role). `@everyone` has the server’s ID.                                                              |
| `channels` | Partial channels and threads, with the person’s `permissions` in each.                                        |
| `messages` | The target [message](https://docs.klang.gg/bots/reference/objects/#message) of a message command, always with its content.                                 |

A user command on Nora:

```json
{
  "id": "1575120622050381826",
  "name": "Wave at",
  "type": 2,
  "target_id": "1575120249231282176",
  "resolved": {
    "users": {
      "1575120249231282176": {
        "id": "1575120249231282176",
        "username": "nora",
        "discriminator": "0",
        "global_name": "Nora",
        "avatar": null,
        "banner": null,
        "accent_color": null,
        "public_flags": 0
      }
    },
    "members": {
      "1575120249231282176": {
        "nick": null,
        "avatar": null,
        "banner": null,
        "roles": [],
        "joined_at": "2026-11-25T12:05:33.189Z",
        "premium_since": null,
        "flags": 0,
        "pending": false,
        "communication_disabled_until": null,
        "permissions": "7328575711604735"
      }
    }
  }
}
```

**For a component** (`3`), a button pressed or a choice made in a select menu:

| Field            | Type             | Present   | Notes                                                                                                     |
| ---------------- | ---------------- | --------- | --------------------------------------------------------------------------------------------------------- |
| `custom_id`      | string           | Always    | The component’s `custom_id`.                                                                              |
| `component_type` | integer          | Always    | `2` a button; `3`, `5`, `6`, `7` or `8` a select menu.                                                    |
| `values`         | array of strings | Sometimes | Select menus: the chosen `value`s, or the IDs of the people, roles or channels, already checked by Klang. |
| `resolved`       | object           | Sometimes | User, role, mentionable and channel menus: `users`, `members`, `roles` and `channels`, as above.          |

Leo chose two boats:

```json
{
  "custom_id": "boats",
  "component_type": 3,
  "values": ["dinghy", "ketch"]
}
```

**For a submitted modal** (`5`):

| Field        | Type   | Present   | Notes                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------ | ------ | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `custom_id`  | string | Always    | The modal’s `custom_id`.                                                                                                                                                                                                                                                                                                                                                                           |
| `components` | array  | Always    | The modal’s components, in order. A label has its `component` with `type`, `id`, `custom_id` and what was sent: `value` for a text input (the text), a radio group (the option, or `null`) and a checkbox (`true` or `false`); `values` for a select menu, a checkbox group and a file upload (the files’ IDs). A text display has only `type` and `id`. The older form comes back as action rows. |
| `resolved`   | object | Sometimes | The people, roles and channels chosen in its menus, as above, and `attachments`: the files of its file uploads, by ID, as [attachments](https://docs.klang.gg/bots/reference/objects/#attachment) with `ephemeral: true`.                                                                                                                                                                                                                       |

There are full examples in [Modals](https://docs.klang.gg/bots/modals/#receive-what-was-sent), and one with files and
choices in [Files, choices and checkboxes](https://docs.klang.gg/bots/modals/#files-choices-and-checkboxes).

## Interaction callback response

What the callback answers with `?with_response=true`, from
[Answer an interaction](https://docs.klang.gg/bots/reference/interactions/#answer-an-interaction).

| Field                                    | Type    | Present   | Notes                                                       |
| ---------------------------------------- | ------- | --------- | ----------------------------------------------------------- |
| `interaction.id`                         | ID      | Always    |                                                             |
| `interaction.type`                       | integer | Always    | The interaction’s type.                                     |
| `interaction.response_message_id`        | ID      | Sometimes | The message a `4` created, or the one a `7` updated.        |
| `interaction.response_message_loading`   | boolean | Sometimes | `true` after a `5`. Not after an `8` or a `9`.              |
| `interaction.response_message_ephemeral` | boolean | Sometimes | Whether the answer is ephemeral. Not after an `8` or a `9`. |
| `resource.type`                          | integer | Always    | The callback’s type.                                        |
| `resource.message`                       | message | Sometimes | The message a `4` created, or the one a `7` updated.        |

## Interaction metadata

On a message that answers an interaction, in `interaction_metadata`.

| Field                            | Type    | Present   | Notes                                                                     |
| -------------------------------- | ------- | --------- | ------------------------------------------------------------------------- |
| `id`                             | ID      | Always    | The interaction.                                                          |
| `type`                           | integer | Always    | `2` a command, `3` a component, `5` a submitted modal.                    |
| `user`                           | user    | Always    | Who used the command, pressed or sent the modal.                          |
| `authorizing_integration_owners` | object  | Always    | As in the [interaction](https://docs.klang.gg/bots/reference/objects/#interaction).                                    |
| `target_message_id`              | ID      | Sometimes | Message commands: the message it was used on.                             |
| `interacted_message_id`          | ID      | Sometimes | Components, and modals a component opened: the message of that component. |

If the account of the person who used the command is deleted, the message keeps its type and
loses `interaction_metadata` and `interaction`. A user command’s `target_user` isn’t sent.

A message command’s answer:

```json
{
  "id": "1575120645949526016",
  "type": 2,
  "user": {
    "id": "1575120252091797504",
    "username": "leo",
    "discriminator": "0",
    "global_name": "Leo",
    "avatar": null,
    "banner": null,
    "accent_color": null,
    "public_flags": 0
  },
  "authorizing_integration_owners": { "0": "1575120255329800192" },
  "target_message_id": "1575120645886611456"
}
```

## Invite

Where an invite leads ([Managing a server](https://docs.klang.gg/bots/reference/management/#create-an-invite)).

| Field                        | Type           | Present       | Notes                                                                                                |
| ---------------------------- | -------------- | ------------- | ---------------------------------------------------------------------------------------------------- |
| `code`                       | string         | Always        |                                                                                                      |
| `type`                       | integer        | Fixed         | `0`: a server.                                                                                       |
| `guild`                      | object         | Always        | `id`, `name`, `icon`, `banner`, `verification_level`; the rest of Discord’s fields, empty or `null`. |
| `channel`                    | object or null | Always        | `id`, `name` and `type`. `null` for a server’s own invite link without a welcome channel.            |
| `inviter`                    | user           | Sometimes     | Who made it. A server’s own invite link has none.                                                    |
| `expires_at`                 | date or null   | Always        | `null` if it never expires.                                                                          |
| `approximate_member_count`   | integer        | `with_counts` | Only on `GET /invites/{invite.code}?with_counts=true`.                                               |
| `approximate_presence_count` | integer        | `with_counts` | The same.                                                                                            |
| `uses`                       | integer        | With metadata | Creating one, and the lists.                                                                         |
| `max_uses`                   | integer        | With metadata | `0` has no limit.                                                                                    |
| `max_age`                    | integer        | With metadata | Seconds it lasts from its creation; `0` never expires.                                               |
| `temporary`                  | boolean        | With metadata | Always `false`.                                                                                      |
| `created_at`                 | date           | With metadata |                                                                                                      |

## Webhook

An incoming webhook of a channel, from the [webhook routes](https://docs.klang.gg/bots/reference/webhooks/).

| Field            | Type         | Present   | Notes                                                                                                    |
| ---------------- | ------------ | --------- | -------------------------------------------------------------------------------------------------------- |
| `id`             | ID           | Always    |                                                                                                          |
| `type`           | integer      | Fixed     | `1`: an incoming webhook. Klang has no other kind.                                                       |
| `guild_id`       | ID           | Always    |                                                                                                          |
| `channel_id`     | ID           | Always    | The text channel it posts to.                                                                            |
| `name`           | string       | Always    | 1 to 80 characters.                                                                                      |
| `avatar`         | hash or null | Always    | Its picture, which libraries load from Klang’s CDN (see [Images](https://docs.klang.gg/bots/libraries/#images)).              |
| `application_id` | null         | Fixed     | `null`: Klang’s webhooks belong to no app, even when a bot created them.                                 |
| `user`           | user         | Sometimes | Who created it, a person or a bot. Not when the account is gone, nor in the answers to the token routes. |
| `token`          | string       | Sometimes | Its secret, 64 characters. Whoever can manage the webhook reads it, as in Discord.                       |
| `url`            | string       | Sometimes | The address that posts with it: `https://api.klang.gg/api/webhooks/{webhook.id}/{webhook.token}`.        |

## Thread member

Someone who follows a thread: Klang’s “follow” is Discord’s “join”
([Threads](https://docs.klang.gg/bots/reference/threads/#who-follows-a-thread)).

| Field            | Type    | Notes           |
| ---------------- | ------- | --------------- |
| `id`             | ID      | The thread.     |
| `user_id`        | ID      | Who follows it. |
| `join_timestamp` | date    | Since when.     |
| `flags`          | integer | Always `0`.     |
