# Interface: types

> Shared data types. Shapes follow the protocol. WIT has no recursive types, so nesting (containers, sections, sub-commands) is 

Generated from `zaun:bot@0.2.0` (`wit/` in [zaun-bot](https://github.com/zaunchat/zaun-bot)). Do not edit.

Shared data types. Shapes follow the protocol. WIT has no recursive types, so nesting (containers, sections,
sub-commands) is spelled out level by level.

## Types

### `id`

*type*

A Zaun id: base64url without padding (22 characters for 16-byte ids).

```wit
type id = string;
```

### `timestamp`

*type*

Milliseconds since the Unix epoch.

```wit
type timestamp = u64;
```

### `permissions`

*type*

A permission bitfield (permissions.md the protocol).

```wit
type permissions = u64;
```

### `host-error`

*record*

What the host refused, mirroring the protocol's error codes.

| Member | Description |
|---|---|
| `code: string` | `FORBIDDEN`, `NOT_FOUND`, `BAD_REQUEST`, `RATE_LIMITED`, `CONFLICT`, `PAYLOAD_TOO_LARGE`, `NOT_GRANTED` (a capability the bot lacks), `UNSUPPORTED` (this host does not implement the call or this case of it yet), ... |
| `detail: option<string>` | The `reason` or `field` the host gave, if any. |
| `retry-after-ms: option<u64>` | For `RATE_LIMITED` and `BUSY`. |

### `member`

*record*

| Member | Description |
|---|---|
| `member-id: id` |  |
| `display-name: string` |  |
| `role-ids: list<id>` |  |
| `joined-at: timestamp` |  |
| `bot-id: option<id>` | Present only for bots. |
| `voice-channel: option<id>` | The voice channel the member is in, if any and if the bot can see that channel. Always filled for an interaction's invoker, so `/play` can join the caller. |

### `role`

*record*

| Member | Description |
|---|---|
| `role-id: id` |  |
| `name: string` |  |
| `color: option<u32>` |  |
| `position: u32` |  |
| `permissions: permissions` |  |
| `managed-by: option<id>` | Set on a bot's managed role. |

### `channel`

*record*

| Member | Description |
|---|---|
| `channel-id: id` |  |
| `name: string` |  |
| `kind: string` | `text`, `announcement`, `voice`, `category`, `dm`, ... |
| `topic: option<string>` |  |
| `parent-id: option<id>` |  |
| `position: u32` |  |
| `participants: list<id>` | A `dm` channel's two members (the bot and the person); empty otherwise. |

### `attachment`

*record*

| Member | Description |
|---|---|
| `attachment-id: id` |  |
| `name: string` |  |
| `size: u64` |  |
| `mime: string` |  |
| `sha3-256: string` | base64url SHA3-256. |

### `embed-author`

*record*

| Member | Description |
|---|---|
| `name: string` |  |
| `url: option<string>` |  |
| `icon: option<id>` |  |

### `embed-footer`

*record*

| Member | Description |
|---|---|
| `text: string` |  |
| `icon: option<id>` |  |

### `embed-field`

*record*

| Member | Description |
|---|---|
| `name: string` |  |
| `value: string` |  |
| `inline: bool` |  |

### `embed`

*record*

| Member | Description |
|---|---|
| `title: option<string>` |  |
| `description: option<string>` |  |
| `url: option<string>` | `https://` only. |
| `color: option<u32>` |  |
| `timestamp: option<timestamp>` |  |
| `author: option<embed-author>` |  |
| `footer: option<embed-footer>` |  |
| `image: option<id>` | Attachment ids of the same message, never URLs. |
| `thumbnail: option<id>` |  |
| `fields: list<embed-field>` |  |

### `button-style`

*enum*

Button styles 1-5; premium (6) is not supported.

| Member | Description |
|---|---|
| `primary` |  |
| `secondary` |  |
| `success` |  |
| `danger` |  |
| `link` |  |

### `button`

*record*

Type 2.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `style: button-style` |  |
| `label: option<string>` |  |
| `emoji: option<string>` | A Unicode emoji. |
| `custom-id: option<string>` | Styles 1-4. |
| `url: option<string>` | Style 5 only: an `https://` link, opened after the reader confirms. |
| `disabled: bool` |  |

### `select-option`

*record*

| Member | Description |
|---|---|
| `label: string` |  |
| `value: string` |  |
| `description: option<string>` |  |
| `emoji: option<string>` |  |
| `is-default: bool` |  |

### `string-select`

*record*

Type 3.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `custom-id: string` |  |
| `options: list<select-option>` |  |
| `placeholder: option<string>` |  |
| `min-values: option<u8>` |  |
| `max-values: option<u8>` |  |
| `required: option<bool>` | In a modal. |
| `disabled: bool` |  |

### `entity-kind`

*enum*

Types 5 (user), 6 (role), 7 (mentionable), 8 (channel).

| Member | Description |
|---|---|
| `user` |  |
| `role` |  |
| `mentionable` |  |
| `channel` |  |

### `default-value-kind`

*enum*

| Member | Description |
|---|---|
| `user` |  |
| `role` |  |
| `channel` |  |

### `default-value`

*record*

| Member | Description |
|---|---|
| `id: id` |  |
| `kind: default-value-kind` |  |

### `entity-select`

*record*

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `kind: entity-kind` |  |
| `custom-id: string` |  |
| `placeholder: option<string>` |  |
| `min-values: option<u8>` |  |
| `max-values: option<u8>` |  |
| `default-values: list<default-value>` |  |
| `channel-types: list<string>` | Channel select only. |
| `required: option<bool>` |  |
| `disabled: bool` |  |

### `row-item`

*variant*

| Member | Description |
|---|---|
| `button(button)` |  |
| `string-select(string-select)` |  |
| `entity-select(entity-select)` |  |

### `action-row`

*record*

Type 1: up to 5 buttons, or one select.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `components: list<row-item>` |  |

### `text-display`

*record*

Type 10.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `content: string` |  |

### `thumbnail`

*record*

Type 11: an image attachment of the same message.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `media: id` |  |
| `description: option<string>` |  |
| `spoiler: bool` |  |

### `section-accessory`

*variant*

| Member | Description |
|---|---|
| `button(button)` |  |
| `thumbnail(thumbnail)` |  |

### `section`

*record*

Type 9: 1-3 text displays and an accessory.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `components: list<text-display>` |  |
| `accessory: section-accessory` |  |

### `media-item`

*record*

| Member | Description |
|---|---|
| `media: id` |  |
| `description: option<string>` |  |
| `spoiler: bool` |  |

### `media-gallery`

*record*

Type 12: 1-10 items.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `items: list<media-item>` |  |

### `file`

*record*

Type 13.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `file: id` |  |
| `spoiler: bool` |  |

### `separator-spacing`

*enum*

| Member | Description |
|---|---|
| `small` |  |
| `large` |  |

### `separator`

*record*

Type 14.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `divider: bool` |  |
| `spacing: separator-spacing` |  |

### `container-child`

*variant*

| Member | Description |
|---|---|
| `action-row(action-row)` |  |
| `text-display(text-display)` |  |
| `section(section)` |  |
| `media-gallery(media-gallery)` |  |
| `file(file)` |  |
| `separator(separator)` |  |

### `container`

*record*

Type 17.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `components: list<container-child>` |  |
| `accent-color: option<u32>` |  |
| `spoiler: bool` |  |

### `component`

*variant*

A top-level message component. Without `components-v2` only `action-row` is allowed.

| Member | Description |
|---|---|
| `action-row(action-row)` |  |
| `text-display(text-display)` |  |
| `section(section)` |  |
| `media-gallery(media-gallery)` |  |
| `file(file)` |  |
| `separator(separator)` |  |
| `container(container)` |  |

### `text-input-style`

*enum*

| Member | Description |
|---|---|
| `short` |  |
| `paragraph` |  |

### `text-input`

*record*

Type 4.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `custom-id: string` |  |
| `style: text-input-style` |  |
| `min-length: option<u16>` |  |
| `max-length: option<u16>` |  |
| `required: option<bool>` |  |
| `value: option<string>` |  |
| `placeholder: option<string>` |  |

### `file-upload`

*record*

Type 19.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `custom-id: string` |  |
| `min-values: option<u8>` |  |
| `max-values: option<u8>` |  |
| `required: option<bool>` |  |

### `choice-option`

*record*

| Member | Description |
|---|---|
| `label: string` |  |
| `value: string` |  |
| `description: option<string>` |  |

### `radio-group`

*record*

Type 21: 2-10 options.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `custom-id: string` |  |
| `options: list<choice-option>` |  |
| `required: option<bool>` |  |

### `checkbox-group`

*record*

Type 22: 1-10 options.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `custom-id: string` |  |
| `options: list<choice-option>` |  |
| `min-values: option<u8>` |  |
| `max-values: option<u8>` |  |
| `required: option<bool>` |  |

### `checkbox`

*record*

Type 23.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `custom-id: string` |  |
| `is-default: bool` |  |

### `label-child`

*variant*

| Member | Description |
|---|---|
| `text-input(text-input)` |  |
| `string-select(string-select)` |  |
| `entity-select(entity-select)` |  |
| `file-upload(file-upload)` |  |
| `radio-group(radio-group)` |  |
| `checkbox-group(checkbox-group)` |  |
| `checkbox(checkbox)` |  |

### `label`

*record*

Type 18.

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `label: string` |  |
| `description: option<string>` |  |
| `component: label-child` |  |

### `modal-item`

*variant*

| Member | Description |
|---|---|
| `label(label)` |  |
| `text-display(text-display)` |  |

### `modal`

*record*

| Member | Description |
|---|---|
| `custom-id: string` |  |
| `title: string` |  |
| `components: list<modal-item>` |  |

### `message-flags`

*flags*

the standard values: 4, 64, 4096, 32768. `LOADING` is host-set only.

| Member | Description |
|---|---|
| `suppress-embeds` |  |
| `ephemeral` |  |
| `suppress-notifications` |  |
| `components-v2` |  |

### `mentions`

*record*

| Member | Description |
|---|---|
| `everyone: bool` |  |
| `members: list<id>` |  |
| `roles: list<id>` |  |

### `message-body`

*record*

What a bot sends: `message.send`, responses, follow-ups and edits.

| Member | Description |
|---|---|
| `content: option<string>` |  |
| `embeds: list<embed>` |  |
| `components: list<component>` |  |
| `attachments: list<id>` | Attachment ids the bot uploaded (`messages.upload`). |
| `mentions: option<mentions>` |  |
| `%flags: message-flags` |  |

### `interaction-metadata`

*record*

| Member | Description |
|---|---|
| `interaction-id: id` |  |
| `kind: u8` |  |
| `name: option<string>` |  |
| `member-id: id` |  |

### `message`

*record*

| Member | Description |
|---|---|
| `message-id: id` |  |
| `channel-id: id` |  |
| `sequence: u64` |  |
| `author-id: id` |  |
| `created-at: timestamp` |  |
| `edited-at: option<timestamp>` |  |
| `content: string` | Empty when the bot lacks `message_content` (unless it is mentioned). |
| `embeds: list<embed>` |  |
| `components: list<component>` |  |
| `%flags: u32` | Raw flag bits. |
| `reply-to: option<id>` |  |
| `mentions: mentions` |  |
| `attachments: list<attachment>` |  |
| `interaction: option<interaction-metadata>` |  |

### `command-kind`

*enum*

Type 1, 2, 3.

| Member | Description |
|---|---|
| `chat-input` |  |
| `user` |  |
| `message` |  |

### `option-kind`

*enum*

Option types 3-11 (1 and 2 are sub-commands and groups).

| Member | Description |
|---|---|
| `%string` |  |
| `integer` |  |
| `boolean` |  |
| `user` |  |
| `channel` |  |
| `role` |  |
| `mentionable` |  |
| `number` |  |
| `attachment` |  |

### `choice-value`

*variant*

| Member | Description |
|---|---|
| `text(string)` |  |
| `integer(s64)` |  |
| `number(f64)` |  |

### `localized`

*record*

| Member | Description |
|---|---|
| `locale: string` |  |
| `text: string` |  |

### `choice`

*record*

| Member | Description |
|---|---|
| `name: string` |  |
| `name-localizations: list<localized>` |  |
| `value: choice-value` |  |

### `command-option`

*record*

| Member | Description |
|---|---|
| `kind: option-kind` |  |
| `name: string` |  |
| `name-localizations: list<localized>` |  |
| `description: string` |  |
| `description-localizations: list<localized>` |  |
| `required: bool` |  |
| `choices: list<choice>` |  |
| `channel-types: list<string>` |  |
| `min-value: option<f64>` |  |
| `max-value: option<f64>` |  |
| `min-length: option<u16>` |  |
| `max-length: option<u16>` |  |
| `autocomplete: bool` |  |

### `sub-command`

*record*

Type 1.

| Member | Description |
|---|---|
| `name: string` |  |
| `name-localizations: list<localized>` |  |
| `description: string` |  |
| `description-localizations: list<localized>` |  |
| `options: list<command-option>` |  |

### `sub-command-group`

*record*

Type 2.

| Member | Description |
|---|---|
| `name: string` |  |
| `name-localizations: list<localized>` |  |
| `description: string` |  |
| `description-localizations: list<localized>` |  |
| `sub-commands: list<sub-command>` |  |

### `command-entry`

*variant*

| Member | Description |
|---|---|
| `value-option(command-option)` |  |
| `sub-command(sub-command)` |  |
| `group(sub-command-group)` |  |

### `application-command`

*record*

| Member | Description |
|---|---|
| `kind: command-kind` |  |
| `name: string` |  |
| `name-localizations: list<localized>` |  |
| `description: string` | Empty for user and message commands. |
| `description-localizations: list<localized>` |  |
| `options: list<command-entry>` |  |
| `default-member-permissions: option<permissions>` | Bits the invoker needs in the channel. `some(0)`: owner only; `none`: everyone. |

### `registered-command`

*record*

| Member | Description |
|---|---|
| `command-id: id` |  |
| `kind: command-kind` |  |
| `name: string` |  |

### `registration`

*record*

What `init` returns.

| Member | Description |
|---|---|
| `commands: list<application-command>` |  |

### `option-value`

*variant*

| Member | Description |
|---|---|
| `text(string)` |  |
| `integer(s64)` |  |
| `boolean(bool)` |  |
| `number(f64)` |  |
| `id(id)` |  |

### `received-option`

*record*

One option the invoker filled in, with the sub-command path flattened onto the data.

| Member | Description |
|---|---|
| `name: string` |  |
| `kind: option-kind` |  |
| `value: option-value` |  |
| `focused: bool` |  |

### `resolved`

*record*

| Member | Description |
|---|---|
| `members: list<member>` |  |
| `roles: list<role>` |  |
| `channels: list<channel>` |  |
| `messages: list<message>` |  |
| `attachments: list<attachment>` |  |

### `command-data`

*record*

| Member | Description |
|---|---|
| `command-id: id` |  |
| `name: string` |  |
| `kind: command-kind` |  |
| `group: option<string>` |  |
| `sub-command: option<string>` |  |
| `options: list<received-option>` |  |
| `resolved: resolved` |  |
| `target-id: option<id>` | The member (user commands) or message (message commands) acted on. |

### `component-data`

*record*

| Member | Description |
|---|---|
| `custom-id: string` |  |
| `component-type: u8` |  |
| `values: list<string>` |  |
| `resolved: resolved` |  |

### `modal-value`

*record*

| Member | Description |
|---|---|
| `id: option<u32>` |  |
| `custom-id: string` |  |
| `component-type: u8` |  |
| `value: option<string>` |  |
| `values: list<string>` |  |

### `modal-data`

*record*

| Member | Description |
|---|---|
| `custom-id: string` |  |
| `components: list<modal-value>` |  |
| `resolved: resolved` |  |

### `interaction-data`

*variant*

| Member | Description |
|---|---|
| `command(command-data)` |  |
| `component(component-data)` |  |
| `autocomplete(command-data)` |  |
| `modal-submit(modal-data)` |  |

### `interaction`

*record*

| Member | Description |
|---|---|
| `interaction-id: id` |  |
| `bot-id: id` |  |
| `channel-id: id` |  |
| `member: member` | The invoker. |
| `app-permissions: permissions` | The bot's effective permissions in the channel. |
| `locale: option<string>` |  |
| `message: option<message>` | For component interactions: the message holding the component. |
| `data: interaction-data` |  |
| `created-at: timestamp` |  |

### `response`

*variant*

Callback types 4-9 (8, the autocomplete result, is the return value of
`on-autocomplete`).

| Member | Description |
|---|---|
| `message(message-body)` | 4: `CHANNEL_MESSAGE_WITH_SOURCE`. |
| `deferred-message(bool)` | 5: `DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE`; `true` = ephemeral. |
| `deferred-update` | 6: `DEFERRED_UPDATE_MESSAGE`. |
| `update-message(message-body)` | 7: `UPDATE_MESSAGE`. |
| `modal(modal)` | 9: `MODAL`. |

### `ready`

*record*

The bot's own identity, once its connection is up.

| Member | Description |
|---|---|
| `bot-id: id` |  |
| `member-id: id` |  |
| `community-id: id` |  |

### `message-event`

*record*

A message, and whether it is in a direct-message channel with the bot.

| Member | Description |
|---|---|
| `message: message` |  |
| `is-dm: bool` |  |

### `message-deleted`

*record*

| Member | Description |
|---|---|
| `channel-id: id` |  |
| `message-id: id` |  |

### `messages-deleted`

*record*

| Member | Description |
|---|---|
| `channel-id: id` |  |
| `message-ids: list<id>` |  |

### `reaction`

*record*

| Member | Description |
|---|---|
| `channel-id: id` |  |
| `message-id: id` |  |
| `emoji: string` |  |
| `member-id: id` |  |

### `member-roles`

*record*

| Member | Description |
|---|---|
| `member-id: id` |  |
| `role-ids: list<id>` |  |

### `member-timeout`

*record*

`until` is `none` when the timeout was cleared.

| Member | Description |
|---|---|
| `member-id: id` |  |
| `until: option<timestamp>` |  |

### `typing`

*record*

| Member | Description |
|---|---|
| `channel-id: id` |  |
| `member-ids: list<id>` |  |

### `activity-type`

*enum*

"Playing {name}", "Streaming {name}", "Listening to {name}", "Watching {name}",
"Competing in {name}", or free text (`custom`).

| Member | Description |
|---|---|
| `playing` |  |
| `streaming` |  |
| `listening` |  |
| `watching` |  |
| `competing` |  |
| `custom` |  |

### `activity`

*record*

What a member (or the bot) is doing.

| Member | Description |
|---|---|
| `kind: activity-type` |  |
| `name: string` | 1-128 characters. |
| `details: option<string>` | <= 128: e.g. the track. |
| `state: option<string>` | <= 128: e.g. the artist. |
| `url: option<string>` | `streaming` only: an `https://` link (open only after the reader confirms). |
| `started-at: option<timestamp>` | When it started, ms since the epoch. |
| `emoji: option<string>` | `custom` only: a Unicode emoji. |

### `presence`

*record*

`status`: `online`, `idle`, `dnd` or `offline` (invisible members look offline).

| Member | Description |
|---|---|
| `member-id: id` |  |
| `status: string` |  |
| `activity: option<activity>` |  |

### `community-profile`

*record*

| Member | Description |
|---|---|
| `system-channel-id: option<id>` |  |
| `default-slowmode-s: u32` |  |

### `event`

*variant*

The events a bot asked for in its manifest (`events`: wire types, groups such as
`messages`, `members`, `dms`, or `*`). Anything without a typed case arrives as
`other` with the event's JSON body.

| Member | Description |
|---|---|
| `ready(ready)` | Always delivered first, once the bot's connection is up. |
| `message-created(message-event)` |  |
| `message-updated(message-event)` |  |
| `message-deleted(message-deleted)` |  |
| `messages-bulk-deleted(messages-deleted)` |  |
| `reaction-added(reaction)` |  |
| `reaction-removed(reaction)` |  |
| `member-joined(member)` | Group `members` (capability `members`). |
| `member-updated(member)` |  |
| `member-left(id)` |  |
| `member-removed(string)` | The bot itself was removed; `reason` is `kicked`, `banned`, ... |
| `member-roles-updated(member-roles)` |  |
| `member-timed-out(member-timeout)` |  |
| `channel-created(channel)` |  |
| `channel-updated(channel)` |  |
| `channel-deleted(id)` |  |
| `role-created(role)` |  |
| `role-updated(role)` |  |
| `role-deleted(id)` |  |
| `typing-started(typing)` |  |
| `presence-updated(presence)` | Group `presence` (capability `presence`). |
| `community-updated(community-profile)` |  |
| `command-updated(id)` | A bot's command list changed; the bot's id. |
| `dm-created(channel)` | Group `dms` (capability `dms`): a DM with the bot was opened, or the bot closed one. |
| `dm-closed(id)` |  |
| `other(raw-event)` |  |

### `raw-event`

*record*

| Member | Description |
|---|---|
| `kind: string` |  |
| `json: string` |  |
