> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloak.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Types

> The objects the SDK hands you: Message, SendOptions, ForumPost, Interaction, Member, Role, and the rest.

These are the data types you receive in event payloads and pass to `Client` methods. The SDK ships full TypeScript declarations, so your editor knows all of this already.

## Message

The payload of a [`messageCreate`](https://docs.cloak.chat/api-reference/events#messagecreate) event, and each element of a [`fetchMessages()`](https://docs.cloak.chat/api-reference/client#fetchmessages) result.

```ts theme={null}
interface Message {
  content: string;
  authorId: string;
  authorName: string;
  messageId: string;
  serverId: string | null;   // null for a DM
  channelId: string;         // for a DM, this is the dm id
  isDM: boolean;
  dmId: string | null;
  createdAt: Date | null;
  repliedTo: {
    messageId: string;
    authorId: string;
    content: string;
    createdAt: Date | null;
  } | null;
  mentions: MessageMentions;
  mentionsMe: boolean;
  attachments: FileAttachment[];
  poll: MessagePoll | null;
  threadId: string | null;
  threadParentId: string | null;
  postId: string | null;
  forumChannelId: string | null;
  starter: boolean;
  card: MessageCard | null;
  reply(text: string, opts?: SendOptions): Promise<void>;
  channel: { send(text: string, opts?: SendOptions): Promise<void> };
  react(reactionId: string): Promise<void>;
  unreact(reactionId: string): Promise<void>;
  edit(newContent: string): Promise<void>;
  delete(): Promise<void>;
  pin(): Promise<void>;
  unpin(): Promise<void>;
  editCard(card: CardEdit): Promise<void>;
  pinned?: boolean;
  command?: CommandInvocation;
}
```

### Fields

**content** `string`

The decrypted message text. Empty string if the key was missing or decryption failed, so check for content before acting on it. Never raw ciphertext.

**authorId** `string`

The sender's normalized id. Compare with `client.user?.id` to detect your bot's own messages.

**authorName** `string`

The sender's display name. This is empty for messages returned by [`fetchMessages()`](https://docs.cloak.chat/api-reference/client#fetchmessages), which does not carry usernames.

**messageId** `string`

The unique id of this message. Cloak message ids are random UUIDs and are not time-sortable.

**serverId** `string | null`

The server the message came from, or **`null` when `isDM` is true**. A direct message has no server at all.

> [!WARNING]
>
> Guard before using it. `if (msg.isDM || !msg.serverId) return;` is the standard first line of a `messageCreate` handler that does server-scoped work. Passing a null value into `client.can()`, `client.guild()`, or `client.send()` is the most common bug in Cloak bots.

**channelId** `string`

The channel the message came from. For a DM this is the dm id, the same value as `dmId`. One convention, so `msg.reply()` and `msg.channel.send()` keep working on a DM without your branching.

**isDM** `boolean`

True when this message arrived as a direct message rather than from a channel. See [Direct messages](https://docs.cloak.chat/guides/direct-messages.md).

**dmId** `string | null`

The dm id for a DM, `null` otherwise. Always equal to `channelId` when set. It exists so `isDM` is not the only way to read the intent.

**createdAt** `Date | null`

The server-generated send time, or `null` when the payload omitted it. `edit`, `editCard`, `delete`, `pin`, `unpin`, `react`, and `unreact` all need this value, so they reject when it is `null`. Live server messages and fetched messages carry it. A DM message carries it on a backend that honors wire version 3, and not on an older one, where the legacy notify signal has no timestamp.

**repliedTo** `object | null`

The context of the message this one replies to, or `null` for a normal message. Its `content` is the decrypted quote, decrypted against the key for the quote's own epoch, and is `''` when it cannot be decrypted. Compare `repliedTo.authorId` with `client.user?.id` to detect a reply to your bot.

On a DM message, set only on a backend that honors wire version 3. `null` on an older backend, whose notify frame carries no reply array.

**mentions** `MessageMentions`

The mentions carried by this message's body. See [MessageMentions](#messagementions).

Derived from the **decrypted body**, not from a wire field. A sender's mention array is routing metadata the server consumes for notification fanout and never echoes back, so the body is the only inbound source. The real Cloak clients decide "was I mentioned" the same way.

**mentionsMe** `boolean`

True when the body carries a `<@id>` entity naming your bot. Direct user mentions only.

`@everyone` and `@here` are `mentions.everyone` and `mentions.here`. A **role** mention cannot be resolved here, because the SDK does not know which roles your bot holds. Role names surface in `mentions.names` for you to check yourself.

**attachments** `FileAttachment[]`

The `[file:id:name]` attachment references carried by this message's decrypted body, in order. Parse-only: an entry proves the sender named a file, not that your bot may read it. Download with [`downloadAttachment()`](https://docs.cloak.chat/api-reference/client#downloadattachment). See [File attachments](https://docs.cloak.chat/guides/file-attachments.md).

**poll** `MessagePoll | null`

The native poll this message carries, or `null` for a plain message. `poll.state` is the server's plaintext structure; `poll.data` is the decrypted question and labels, best-effort, and `null` (never ciphertext) when the key is missing. Watch [`pollUpdate`](https://docs.cloak.chat/api-reference/events#pollupdate) for tallies. See [Polls](https://docs.cloak.chat/guides/polls.md).

**threadId** `string | null`

The thread this message was sent into, or `null` for a channel or DM message. When set, `channelId` is the same id: a thread's replies are ordinary messages whose channel is the thread, and `reply()` and `channel.send()` route back into it. See [Threads](https://docs.cloak.chat/guides/threads.md).

**threadParentId** `string | null`

The thread's parent text channel, when the SDK knows it, resolved from its thread index. In practice `null` only when event ordering breaks; `reply()` on a thread message needs it and rejects without it.

**postId** `string | null`

The forum post this message was sent into, or `null`. When set, `channelId` is the same id and `threadId` is `null`. `reply()` and `channel.send()` route back into the post. See [Forums](https://docs.cloak.chat/guides/forums.md).

**forumChannelId** `string | null`

The parent forum channel of `postId`, or `null`. Unlike a thread's parent, this is always known when `postId` is set, because a post frame carries it on the wire.

**starter** `boolean`

True for a forum post's first message. The starter never rides the ordinary message stream: the SDK emits it from the post's create event, once, with `messageId` equal to `ForumPost.starterMessageId`, right before the matching `forumPostUpdate`.

**card** `MessageCard | null`

The encrypted card this message carries, decrypted with the key for its own epoch: every embed that survived the read-side validator, plus the component rows. `null` for a plain message, and `null` (never a partial card) when the payload fails a cap or the media rule. Present on live messages and on `fetchMessages()` rows. On a DM message it is populated only on a backend that honors wire version 3, including the echo of your own `sendCardDM()`. See [MessageCard](https://docs.cloak.chat/api-reference/embeds.md#messagecard).

**pinned** `boolean`

Whether the message is pinned, when known. Present on messages from [`fetchMessages()`](https://docs.cloak.chat/api-reference/client#fetchmessages) and after a [`pinUpdate`](https://docs.cloak.chat/api-reference/events#pinupdate).

**command** `CommandInvocation | undefined`

The slash-command invocation this message carries, when it is one your registry recognizes. Plain data with no back-reference to the message.

Filter with `if (msg.command) return;` in a `messageCreate` handler that also does its own text handling, so you do not process an invocation twice. Never set on fetched history (server or DM) or on your bot's own messages. Set on a DM message when the invocation came from the DM's `/` picker on a wire version 3 backend. See [CommandInvocation](https://docs.cloak.chat/api-reference/commands.md#commandinvocation) and [CommandContext](https://docs.cloak.chat/api-reference/commands.md#commandcontext) for the `serverId`, `dmId`, `channelId`, and `userId` a handler receives.

### Methods

**reply** `(text: string, opts?: SendOptions) =\> Promise\<void\>`

Sends a **true reply** into the same channel or DM: it renders a quote header and fires a "replied to you" notification that pierces mutes.

Use it when your bot is genuinely answering a specific message. For a plain response, use `channel.send()`.

It degrades to a plain send, and never throws, when the message has no `createdAt`, because the reply pointer cannot be built without the server's own send time.

**channel.send** `(text: string, opts?: SendOptions) =\> Promise\<void\>`

A plain send into the same channel or DM, with no quote header and no reply notification. This is what a ping bot wants.

**react** `(reactionId: string) =\> Promise\<void\>`

Adds a reaction. `reactionId` is opaque: a unicode emoji, or a custom emoji id from [`fetchEmojis()`](https://docs.cloak.chat/api-reference/client#fetchemojis). Requires `reaction_add`. See [Reactions](https://docs.cloak.chat/guides/reactions.md).

**unreact** `(reactionId: string) =\> Promise\<void\>`

Removes your bot's own reaction.

**edit** `(newContent: string) =\> Promise\<void\>`

Edits the message. Author only, server-side. Re-encrypts with the channel's current epoch key, exactly like `send()`. See [Editing, deleting, and pinning](https://docs.cloak.chat/guides/editing-and-pinning.md).

**delete** `() =\> Promise\<void\>`

Deletes the message. Author, or a member with `message_manage` for others' messages.

**pin** `() =\> Promise\<void\>`

Pins the message. Author, or a member with the channel's pin permission.

**unpin** `() =\> Promise\<void\>`

Unpins the message.

**editCard** `(card: CardEdit) =\> Promise\<void\>`

Replaces this message's card (embed and component rows) and re-encrypts its text in one edit. Author only, server-side. Fills in the location and `createdAt` that [`client.editCard()`](https://docs.cloak.chat/api-reference/client#editcard) needs, including the `null` server id of a DM. Pass `components: []` to retire a card's buttons. See [Buttons and selects](https://docs.cloak.chat/guides/components.md#retire-the-controls).

`react`, `unreact`, `edit`, `delete`, `pin`, `unpin`, and `editCard` reject with [`CloakActionError`](https://docs.cloak.chat/api-reference/errors) on a server deny.

> [!WARNING]
>
> `pin()` and `unpin()` reject **unconditionally on a DM message**, with a plain `Error`, before anything reaches the wire. The other five work on a DM message that carries `createdAt`, which needs a backend that honors wire version 3; without a timestamp they reject with a plain `Error` saying so. `reply()` and `channel.send()` work everywhere. See [Direct messages](https://docs.cloak.chat/guides/direct-messages.md#what-a-wire-version-3-backend-adds).

`reply()` and `channel.send()` are fire-and-forget for delivery and do not reject on a deny. A denial arrives on [`sendRejected`](https://docs.cloak.chat/api-reference/events#sendrejected). See [Handling errors](https://docs.cloak.chat/guides/handling-errors.md).

## SendOptions

The options object every send-shaped call takes: [`send()`](https://docs.cloak.chat/api-reference/client#send), `msg.reply()`, `msg.channel.send()`, `guild().send()`, and [`sendDM()`](https://docs.cloak.chat/api-reference/client#senddm).

```ts theme={null}
interface SendOptions {
  groupId?: string;
  mentions?: MentionTarget[];
  replyTo?: ReplyTarget;
  poll?: PollCreate;
  threadId?: string;
  postId?: string;
  ack?: boolean;
  ackTimeoutMs?: number;
}
```

**groupId** `string`

The channel's group, for the rare case where the SDK has not already cached it from an inbound frame.

**mentions** `MentionTarget[]`

Who to notify.

> [!WARNING]
>
> Mention targets are sent in **plaintext**. The server routes notification fanout without decrypting the message body, so who your bot pinged is visible server-side even though what it said is not. This is Cloak's design. See [Encryption lanes](https://docs.cloak.chat/concepts/encryption-lanes.md).

A mention is two independent halves and you supply both. This array is the ping. The pill is literal text in the body, produced by `userMention()`, `roleMention()`, `EVERYONE`, or `HERE`. The SDK never scans your outgoing text to synthesize the array. See [Mentions](https://docs.cloak.chat/api-reference/mentions.md).

**replyTo** `ReplyTarget`

Makes this send a true reply: it renders the quote header and fires the "replied to you" notification.

**poll** `PollCreate`

Attach a native poll to this message. The question and option labels are end-to-end encrypted; the structure (option count, window, flags) is plaintext, because the server validates and tallies votes. Server sends need the create-polls capability, DM polls are ungated, and bots never vote: the backend refuses a bot vote by design. See [Polls](https://docs.cloak.chat/guides/polls.md).

**threadId** `string`

Target this send at a thread of the channel. Pass the parent text channel as `channelId` and the thread's id here. Requires `send_in_thread`; a locked, deleted, or inaccessible private thread denies on [`sendRejected`](https://docs.cloak.chat/api-reference/events#sendrejected). Not valid on DM sends. Mutually exclusive with `postId`. See [Threads](https://docs.cloak.chat/guides/threads.md).

**postId** `string`

Target this send at a forum post. Pass the parent **forum** channel as `channelId` and the post's id here. The SDK enters the post, which moves the session cursor, and sends the ordinary frame. A locked post denies `-18` on `sendRejected`; a send into the forum channel with no `postId` denies `-17`. Not valid on DM sends. Mutually exclusive with `threadId`. See [Forums](https://docs.cloak.chat/guides/forums.md).

**ack** `boolean`

Resolve with the persisted `Message` instead of `void`. The SDK matches the bot's own firehose echo back to the send by its ciphertext and resolves when it lands, so a resolved promise means the server persisted the row. A denial pinned to this send rejects with `CloakActionError`; no echo and no deny inside `ackTimeoutMs`, a socket drop while waiting, or a deny that could belong to several outstanding sends rejects with [`CloakSendTimeoutError`](https://docs.cloak.chat/api-reference/errors#cloaksendtimeouterror), whose outcome is indeterminate. The wait does not hold the send chain. A DM echo needs a backend that honors wire version 3. See [Sending is fire-and-forget unless you ask for a receipt](https://docs.cloak.chat/concepts/message-delivery.md#sending-is-fire-and-forget-unless-you-ask-for-a-receipt).

**ackTimeoutMs** `number` (default: 15000)

How long an `ack: true` send waits for its echo.

> [!WARNING]
>
> This object replaced a positional `groupId` fourth argument in 0.2.0, and the positional form is gone. `send(s, c, text, groupId)` becomes `send(s, c, text, { groupId })`.

## BotCapabilities

What [`capabilities()`](https://docs.cloak.chat/api-reference/client#capabilities) returns: the backend's own declaration, at login, of which optional behaviors this deployment has. Every flag is a behavior the SDK would otherwise have to probe or assume.

```ts theme={null}
interface BotCapabilities {
  wire: number;                // the wire version the session was accepted at
  replay: boolean;             // resume replay is armed for this session
  sendAck: boolean;            // the bot-only send ack is on (wire >= 4)
  sendNonce: boolean;          // the send nonce is echoed on a denial and deduplicated
  reactionOp: boolean;         // reactionUpdate.operation is authoritative
  deleteActor: boolean;        // messageDelete.actorId is carried
  typingRouting: boolean;      // the typing event carries serverId / channelId
  containerParents: boolean;   // container frames and hooks carry kind + parent
  resolveContainer: boolean;   // resolveContainer() exists
  fetchMessage: boolean;       // fetchMessage() exists
  starterReactionAck: boolean; // reactToStarter() is answered with a verdict
  rest: boolean;               // bot REST credentials are enabled server-side
  rateLimitEnforced: boolean;  // opcode rate limiting is enforced, not observe-only
}
```

`null` from `capabilities()` means the backend sent no map; treat every flag as false.

## SendFileOptions

```ts theme={null}
type SendFileOptions = SendOptions & { text?: string; signal?: AbortSignal };
```

What [`sendFile()`](https://docs.cloak.chat/api-reference/client#sendfile) and [`sendFiles()`](https://docs.cloak.chat/api-reference/client#sendfiles) take: every send option plus the caption and a signal that cancels the upload and grant legs.

## FileInput

```ts theme={null}
interface FileInput {
  name: string;
  bytes: Buffer;
  contentType?: string;
}
```

One file to attach. `contentType` defaults to `application/octet-stream`; the SDK never sniffs. The bytes are encrypted before they leave the host.

## TypingTarget

```ts theme={null}
interface TypingTarget {
  groupId?: string;
  threadId?: string;
  postId?: string;
}
```

The optional fourth argument of [`sendTyping()`](https://docs.cloak.chat/api-reference/client#sendtyping): the channel's group, or one container to type in.

## ReplyTarget

The message a send is replying to. A received `Message` satisfies it structurally, so `{ replyTo: msg }` just works.

```ts theme={null}
type ReplyTarget = Pick<Message, 'messageId' | 'authorId' | 'createdAt'>;
```

All three fields ride the wire together, and the server re-reads the original row using all three as a compound key. `createdAt` must therefore be the server's own send time, which is exactly what the SDK puts there. The target must live in the channel you are sending to. A target with no `createdAt` cannot be used, so building a reply slot from one throws.

## MentionTarget

One entry in [`SendOptions.mentions`](#sendoptions). Ids may be dashed or undashed.

```ts theme={null}
type MentionTarget =
  | { userId: string }
  | { roleId: string }
  | 'everyone'
  | 'here';
```

Role, `@everyone`, and `@here` targets are dropped server-side inside a DM. Only direct user mentions produce a notification there. See [Mentions](https://docs.cloak.chat/api-reference/mentions.md).

## MessageMentions

What the SDK recovers from a decrypted message body, exposed as [`Message.mentions`](#message).

```ts theme={null}
interface MessageMentions {
  userIds: string[];
  names: string[];
  everyone: boolean;
  here: boolean;
}
```

**userIds** `string[]`

Normalized ids from `<@id>` user-mention entities in the body.

**names** `string[]`

Literal `@name` tokens that are not `@everyone` or `@here` and not an id entity. A name may be a role, an older-style user mention, or just text. The SDK cannot tell them apart without the server's roster, so compare against [`fetchRoles()`](https://docs.cloak.chat/api-reference/client#fetchroles) if you need to.

A multi-word role name yields only its first word here, because the SDK has no role list at decode time.

**everyone** `boolean`

True when the body carries `@everyone`. Matched case-insensitively, like the real clients.

**here** `boolean`

True when the body carries `@here`.

## SystemMessageEvent

The payload of a [`systemMessage`](https://docs.cloak.chat/api-reference/events#systemmessage) event.

```ts theme={null}
interface SystemMessageEvent {
  type: 'member_join' | 'bot_add' | 'thread_created' | 'unknown';
  actorId: string;
  actorName: string;
  serverId: string;
  channelId: string;
  groupId?: string;
  threadId?: string;
}
```

**type** `'member_join' | 'bot_add' | 'thread_created' | 'unknown'`

Which system event this is.

**actorId** `string`

The id of the member the event is about, such as the person who joined.

**actorName** `string`

The display name of that member.

**serverId** `string`

The server the event happened in. Not nullable: system messages are always server events.

**channelId** `string`

The channel the event is associated with.

**groupId** `string`

The group of the source channel, where known. Pass it to `send()` so the message lands in the right channel. It can be `undefined` if the channel's group has not been seen yet.

**threadId** `string`

For `type: 'thread_created'`: the new thread's id. `channelId` is the parent text channel the system row lives in; the thread's title arrives on its own [`threadUpdate`](https://docs.cloak.chat/api-reference/events#threadupdate). See [Threads](https://docs.cloak.chat/guides/threads.md).

## ForumPost

One post of a forum channel. The payload of [`forumPostUpdate`](https://docs.cloak.chat/api-reference/events#forumpostupdate), the result of [`createForumPost()`](https://docs.cloak.chat/api-reference/client#createforumpost), and each element of a [`fetchForumPosts()`](https://docs.cloak.chat/api-reference/client#fetchforumposts) page.

```ts theme={null}
interface ForumPost {
  postId: string;
  serverId: string;
  forumChannelId: string;
  title: string;
  authorId: string;
  authorName: string;
  createdAt: Date | null;
  lastActiveAt: Date | null;
  replyCount: number;
  tagIds: number[];
  archived: boolean;
  locked: boolean;
  pinned: boolean;
  answered: { messageId: string; at: Date | null; authorId: string } | null;
  starterMessageId: string | null;
  starterContent: string | null;
  following: boolean;
}
```

**forumChannelId** `string`

The parent forum channel the post lives in.

**title** `string`

Decrypted best-effort with the server key for the ciphertext's own epoch. `''` (never ciphertext) when the key is missing.

**tagIds** `number[]`

The applied tag ids. Resolve names through [`fetchForumMeta()`](https://docs.cloak.chat/api-reference/client#fetchforummeta).

**archived** `boolean`

The computed archive verdict: the manual flag folded with the forum's lazy auto-archive.

**locked** `boolean`

A locked post rejects replies with `-18` on `sendRejected`.

**answered** `object | null`

The accepted answer, when the post is marked solved. Set with `setForumPostState(..., 'answered', msg)`.

**starterMessageId** `string | null`

The post's first message. `null` only on the row `createForumPost()` synthesizes when the server's own create event has not arrived in time.

**starterContent** `string | null`

The starter's decrypted body when the row carried it (a `fetchForumPosts()` page, or the create event). `null` otherwise, including on activity bumps.

**following** `boolean`

Whether this bot follows the post. Known from the rows that carry it; `false` when the row did not say.

## ForumTag

One tag of a forum channel, carried on [`ForumMeta`](#forummeta). The name is end-to-end encrypted like a post title and decrypted best-effort.

```ts theme={null}
interface ForumTag {
  id: number;
  name: string;
  emoji: string;
  moderated: boolean;
}
```

`moderated: true` means only a member who may manage posts can apply it.

## ForumMeta

A forum channel's settings, returned by [`fetchForumMeta()`](https://docs.cloak.chat/api-reference/client#fetchforummeta).

```ts theme={null}
interface ForumMeta {
  serverId: string;
  forumChannelId: string;
  tags: ForumTag[];
  guidelines: string;
  requireTag: boolean;
  defaultSort: 'activity' | 'created';
  autoArchiveDays: number;
  defaultReaction: string;
  totalPosts: number;
}
```

`guidelines` is decrypted best-effort and `''` when absent or the key is missing. `requireTag: true` means `createForumPost()` without a tag denies `-4`.

## ForumPostStateFieldName

The `field` argument of [`setForumPostState()`](https://docs.cloak.chat/api-reference/client#setforumpoststate).

```ts theme={null}
type ForumPostStateFieldName = 'archived' | 'locked' | 'pinned' | 'answered' | 'move';
```

## Interaction

The payload of the [`interaction`](https://docs.cloak.chat/api-reference/events#interaction) event: one click, select, or modal submit on a card your bot posted. It was encrypted by the clicker with the conversation key and pushed to your bot alone.

```ts theme={null}
interface Interaction {
  id: string;
  kind: 'button' | 'select' | 'modal';
  customId: string;
  values: string[];
  fields: Record<string, string>;
  parentId: string | null;
  userId: string;
  botId: string;
  messageId: string;
  serverId: string | null;
  channelId: string;
  threadId: string | null;
  postId: string | null;
  createdAt: Date | null;
  ack(): Promise<void>;
  showModal(def: ModalDefinition): Promise<void>;
  ephemeral(reply: EphemeralMessage): Promise<void>;
}
```

### Fields

**id** `string`

The server-minted interaction id. Valid for 15 minutes after the click.

**kind** `'button' | 'select' | 'modal'`

What produced it.

**customId** `string`

The button's, select's, or modal's `customId`, verbatim.

**values** `string[]`

A select's chosen option values. Empty for a button or a modal.

**fields** `Record\<string, string\>`

A modal's input values keyed by input `customId`. Empty otherwise.

**parentId** `string | null`

For a modal submit, the id of the click that opened it. For a click on a row inside an ephemeral reply, the interaction that produced that reply. `null` otherwise.

**userId** `string`

Who clicked, normalized.

**botId** `string`

The addressed bot. Always this one: the SDK drops clicks addressed to another bot.

**messageId** `string`

The message the control lives on. A click inside an ephemeral reply carries the **original** message id.

**serverId** `string | null`

The server, or `null` for a click inside a DM.

**channelId** `string`

The id the message lives in: a thread or post id when inside one, the dm id in a DM.

**threadId** `string | null`

Set when `channelId` is a thread the SDK's thread index knows.

**postId** `string | null`

Set when `channelId` is a forum post the SDK's post index knows.

**createdAt** `Date | null`

When the click happened. This is not the message's send time, so it cannot be passed to `editCard()`.

### Methods

Answer with **exactly one** of these. A second call rejects locally with a [`CloakClientError`](https://docs.cloak.chat/api-reference/errors#cloakclienterror) whose `source` is `'interaction'`, before any frame goes out, and the server refuses it too. A server-side refusal rejects with [`CloakActionError`](https://docs.cloak.chat/api-reference/errors#interaction-responses).

**ack** `() =\> Promise\<void\>`

Clear the clicker's pending state and show nothing.

**showModal** `(def: ModalDefinition) =\> Promise\<void\>`

Open a modal on the clicker's screen. Its submit arrives as a fresh `interaction` with `kind: 'modal'` and `parentId` equal to this id. Validated locally before anything is encrypted. See [Modals](https://docs.cloak.chat/guides/modals.md).

**ephemeral** `(reply: EphemeralMessage) =\> Promise\<void\>`

Show the clicker, and nobody else, a reply under the message. Never stored. Rows inside it are clickable. See [EphemeralMessage](https://docs.cloak.chat/api-reference/embeds.md#ephemeralmessage).

## Member

One server member.

> [!WARNING]
>
> The only producer of `Member[]` is [`fetchMembers()`](https://docs.cloak.chat/api-reference/client#fetchmembers), which **hangs against every current Cloak backend**. The shape below survives the eventual fix, so code written against it stays valid, but you cannot obtain one today.

```ts theme={null}
interface Member {
  userId: string;
  username: string;
  status: number;
  createdAt: Date | null;
  icon: string | null;
  subscriptionTier: number | null;
  isBot: boolean;
  role: MemberRole | null;
}
```

## MemberSearchResult

One [`searchMembers()`](https://docs.cloak.chat/api-reference/client#searchmembers) hit. Richer than `Member`: the search lane carries the display name and nickname.

```ts theme={null}
interface MemberSearchResult {
  userId: string;
  username: string;
  displayName: string;
  nickname: string;
  icon: string | null;
  status: number;
  isBot: boolean;
  subscriptionTier: number | null;
  role: MemberRole | null;
  onMobile: boolean;
}
```

`nickname` is `''` when none is set. `role` is the member's primary role, or `null` when they have none or the server hides role buckets for offline members.

**userId** `string`

The member's normalized id.

**username** `string`

The member's display name.

**status** `number`

Online status code, where `0` means offline.

**createdAt** `Date | null`

Account creation time, not the time the member joined the server, when known.

**icon** `string | null`

The member's avatar reference, or `null`.

**subscriptionTier** `number | null`

The member's subscription tier, or `null`.

**isBot** `boolean`

Whether the member is a bot.

**role** `MemberRole | null`

The member's assigned role, or `null`.

## MemberRole

A member's assigned role, carried on [`Member`](#member).

```ts theme={null}
interface MemberRole {
  id: string;
  name: string;
  color: string | null;
  secondColor: string | null;
  admin: boolean;
}
```

**id** `string`

The role's normalized id.

**name** `string`

The role's name.

**color** `string | null`

The role's primary color, or `null`.

**secondColor** `string | null`

The role's secondary color, or `null`.

**admin** `boolean`

Whether the role confers admin standing.

## Role

One server role, returned by [`fetchRoles()`](https://docs.cloak.chat/api-reference/client#fetchroles).

```ts theme={null}
interface Role {
  id: string;
  name: string;
  color: string | null;
  secondColor: string | null;
  position: number | null;
  memberCount: number;
}
```

**id** `string`

The role's normalized id.

**name** `string`

The role's name.

**color** `string | null`

The role's primary color, or `null`.

**secondColor** `string | null`

The role's secondary color, or `null`.

**position** `number | null`

The role's position in the ordering, or `null`. Lower numbers sort higher.

**memberCount** `number`

How many members hold the role.

## BanInfo

One entry in a server's ban list, returned by [`fetchBans()`](https://docs.cloak.chat/api-reference/client#fetchbans).

```ts theme={null}
interface BanInfo {
  userId: string;
  username: string | null;
  bannedAt: Date | null;
  reason: string;
}
```

**userId** `string`

The banned member's normalized id.

**username** `string | null`

The resolved display name, or `null` when the account no longer resolves.

**bannedAt** `Date | null`

When the ban was recorded, when known.

**reason** `string`

The stored ban reason, or an empty string.

## MessageLocation

The remembered location of a message the bot has seen, returned by [`messageLocation()`](https://docs.cloak.chat/api-reference/client#messagelocation).

```ts theme={null}
interface MessageLocation {
  serverId: string | null;
  channelId: string;
  groupId?: string;
  authorId: string;
  createdAtMs: number | null;
}
```

**serverId** `string | null`

The server the message is in, or `null` for a DM. When it is `null`, `channelId` holds the dm id.

**channelId** `string`

The channel the message is in.

**groupId** `string`

The channel's group, where known.

**authorId** `string`

The message author's normalized id.

**createdAtMs** `number | null`

The message's send time in milliseconds, or `null`.

## ChannelInfo

One channel of a server, returned by [`fetchChannels()`](https://docs.cloak.chat/api-reference/client#fetchchannels) and [`getChannel()`](https://docs.cloak.chat/api-reference/client#getchannel).

```ts theme={null}
interface ChannelInfo {
  id: string;
  name: string;
  groupId: string;
  type: number;
  order: number;
  lastMessageAt: Date | null;
}
```

**id** `string`

The channel's normalized id, in the same shape as every other id the SDK hands you.

**name** `string`

The channel's name.

**groupId** `string`

The channel's group, which the Cloak clients call a category. This is the value `SendOptions.groupId` and `deleteChannel()` want.

**type** `number`

What kind of channel this is. Compare against [`ChannelType`](#channeltype).

Deliberately a plain `number` rather than a narrowed union, so a channel kind newer than your installed SDK still appears in the list with its wire code intact instead of being dropped or mislabelled.

**order** `number`

The channel's sort position within its group.

**lastMessageAt** `Date | null`

When the channel last received a message, or `null` if it never has. Always `null` on channel kinds that do not carry messages.

> [!NOTE]
>
> The channel list is filtered server-side to what your bot may view, so an absent channel is one the bot cannot see rather than one that does not exist. The SDK does no permission math of its own.

## ChannelType

The named channel-type codes, for comparing against [`ChannelInfo.type`](#channelinfo) and for passing to [`createChannel()`](https://docs.cloak.chat/api-reference/client#createchannel).

```ts theme={null}
const ChannelType = {
  TEXT: 0,
  VOICE: 1,
  CALENDAR: 2,
  BOARD: 3,
  FORUM: 4,
  TICKET: 5,
} as const;
```

```ts theme={null}
import { ChannelType, channelTypeName } from '@cloak-software/bot-sdk';

const channels = await client.fetchChannels(serverId);
const voice = channels.filter((c) => c.type === ChannelType.VOICE);

channelTypeName(1); // 'VOICE'
channelTypeName(99); // undefined
```

Text and voice are the two your bot is most likely to care about: text channels are where `send()` works, and voice channels are what [`joinVoice()`](https://docs.cloak.chat/api-reference/client#joinvoice) accepts.

> [!NOTE]
>
> This list is what Cloak ships today, and it grows. Treat an unrecognized `type` as a channel kind your SDK predates rather than as bad data. `channelTypeName(code)` returns the name for a known code and `undefined` for anything else, which is the cheapest way to tell the two apart.

> [!WARNING]
>
> A channel created before Cloak had channel types carries no type on the wire. The SDK reports those as `ChannelType.TEXT`, which is what they are and what every Cloak client treats them as. You will never see a `null` here.

## VoiceConnection

Your bot's own voice membership, returned by [`joinVoice()`](https://docs.cloak.chat/api-reference/client#joinvoice) and [`voiceConnection()`](https://docs.cloak.chat/api-reference/client#voiceconnection).

```ts theme={null}
interface VoiceConnection {
  serverId: string;
  channelId: string;
  groupId: string;
  token: string;
  url: string;
  selfMuted: boolean;
  selfDeafened: boolean;
  joinedAt: Date;
}
```

**token** `string`

The LiveKit credential the backend minted, opaque to the SDK.

> [!WARNING]
>
> This is a live credential. Never log it. A bot session's grant is microphone-only, so a bot cannot publish video with it whatever permissions it holds.

**url** `string`

The LiveKit signalling url: `ClientOptions.livekitUrl`, or the value derived from your transport url. The SDK makes no connection to it. Hand it, with the token, to a media layer. See [Voice audio](https://docs.cloak.chat/voice/audio.md).

**selfDeafened** `boolean`

The broadcast deafen flag, not an answer to "can I hear". Whether the bot receives audio is decided by `voice_listen` and the scope of its voice key.

## VoiceParticipant

One member of a voice channel's roster, from [`voiceRoster()`](https://docs.cloak.chat/api-reference/client#voiceroster) and the [`voiceJoin`](https://docs.cloak.chat/api-reference/events#voicejoin) event. Eventually consistent.

```ts theme={null}
interface VoiceParticipant {
  userId: string;
  channelId: string;
  muted: boolean;
  deafened: boolean;
  serverMuted: boolean;
  serverDeafened: boolean;
  webcam: boolean;
  stream: boolean;
  reconnecting: boolean;
  // Deprecated. P2P was removed from the platform, so both are always false.
  p2pWebcam: boolean;
  p2pStream: boolean;
}
```

**reconnecting** `boolean`

True while the member's voice session is inside the backend's 60 second reconnect grace window.

> [!WARNING]
>
> `p2pWebcam` and `p2pStream` are **deprecated and permanently `false`**. Peer-to-peer video is deleted from the Cloak platform, and the wire columns those fields read no longer exist. Do not treat them as capability flags.

`serverMuted` and `serverDeafened` come from a separate server-side query and are best-effort. The other flags are reliable.

## BotStatus

The named presence values [`setStatus()`](https://docs.cloak.chat/api-reference/client#setstatus) accepts.

```ts theme={null}
type BotStatus = 'invisible' | 'online' | 'away' | 'busy' | 'dnd';
```

`dnd` also suppresses push notifications on every device. `busy` does not. `online` defers to session liveness rather than pinning a green dot.

## VoiceStateFlag

Which flag changed on a [`voiceStateUpdate`](https://docs.cloak.chat/api-reference/events#voicestateupdate) event.

```ts theme={null}
type VoiceStateFlag = 'muted' | 'deafened' | 'webcam' | 'stream' | 'p2pWebcam' | 'p2pStream';
```

The last two are dead values that can no longer arrive, for the same reason as the `VoiceParticipant` fields above.

## Guild

The payload of [`guildCreate`](https://docs.cloak.chat/api-reference/events#guildcreate) and [`guildDelete`](https://docs.cloak.chat/api-reference/events#guilddelete). A server is called a guild here, matching the discord.js naming.

```ts theme={null}
interface Guild {
  id: string;
}
```

## BotUser

Your bot's identity, available as `client.user` after login.

```ts theme={null}
interface BotUser {
  id: string;
  username: string;
}
```

**id** `string`

Your bot's normalized id. Compare it against `msg.authorId` to ignore your bot's own messages.

**username** `string`

Your bot's username.

## PermissionSet

The resolved capability set for one server: 43 named booleans plus a numeric rank. Returned by [`permissions()`](https://docs.cloak.chat/api-reference/client#permissions) and spread into the [`permissionsUpdate`](https://docs.cloak.chat/api-reference/events#permissionsupdate) payload.

```ts theme={null}
type PermissionSet = { effectiveRank: number } & Record<PermissionName, boolean>;
```

Documented in full, with every permission name, on [Permissions](https://docs.cloak.chat/api-reference/permissions.md#permissionset).

## Next

> [card] [Errors](https://docs.cloak.chat/api-reference/errors.md)
>
> Every error class an action can reject with.

> [card] [Permissions](https://docs.cloak.chat/api-reference/permissions.md)
>
> All 43 permission names.

> [card] [Events](https://docs.cloak.chat/api-reference/events.md)
>
> Where these types come from.

> [card] [Client](https://docs.cloak.chat/api-reference/client.md)
>
> The methods that return them.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.