Client methods. The SDK ships full TypeScript declarations, so your editor knows all of this already.
Message
The payload of amessageCreate event, and each element of a fetchMessages() result.
Fields
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.
string
The sender’s normalized id. Compare with
client.user?.id to detect your bot’s own messages.string
The sender’s display name. This is empty for messages returned by
fetchMessages(), which does not carry usernames.string
The unique id of this message. Cloak message ids are random UUIDs and are not time-sortable.
string | null
The server the message came from, or
null when isDM is true. A direct message has no server at all.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.boolean
True when this message arrived as a direct message rather than from a channel. See Direct messages.
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.Date | null
The server-generated send time, or
null when the payload omitted it. edit, delete, pin, unpin, react, and unreact all need this value, so they reject when it is null. Live and fetched messages carry it.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.Always null on a DM message.MessageMentions
The mentions carried by this message’s body. See 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.
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.boolean
Whether the message is pinned, when known. Present on messages from
fetchMessages() and after a pinUpdate.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 or on your bot’s own messages. See CommandInvocation.Methods
(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.(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.
(reactionId: string) => Promise<void>
Adds a reaction.
reactionId is opaque: a unicode emoji, or a custom emoji id from fetchEmojis(). Requires reaction_add. See Reactions.(reactionId: string) => Promise<void>
Removes your bot’s own reaction.
(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.() => Promise<void>
Deletes the message. Author, or a member with
message_manage for others’ messages.() => Promise<void>
Pins the message. Author, or a member with the channel’s pin permission.
() => Promise<void>
Unpins the message.
react, unreact, edit, delete, pin, and unpin reject with CloakActionError on a server deny.
reply() and channel.send() are fire-and-forget for delivery and do not reject on a deny. A denial arrives on sendRejected. See Handling errors.
SendOptions
The options object every send-shaped call takes:send(), msg.reply(), msg.channel.send(), guild().send(), and sendDM().
string
The channel’s group, for the rare case where the SDK has not already cached it from an inbound frame.
MentionTarget[]
Who to notify.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.ReplyTarget
Makes this send a true reply: it renders the quote header and fires the “replied to you” notification.
ReplyTarget
The message a send is replying to. A receivedMessage satisfies it structurally, so { replyTo: msg } just works.
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 inSendOptions.mentions. Ids may be dashed or undashed.
@everyone, and @here targets are dropped server-side inside a DM. Only direct user mentions produce a notification there. See Mentions.
MessageMentions
What the SDK recovers from a decrypted message body, exposed asMessage.mentions.
string[]
Normalized ids from
<@id> user-mention entities in the body.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() 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.boolean
True when the body carries
@everyone. Matched case-insensitively, like the real clients.boolean
True when the body carries
@here.SystemMessageEvent
The payload of asystemMessage event.
'member_join' | 'bot_add' | 'unknown'
Which system event this is.
string
The id of the member the event is about, such as the person who joined.
string
The display name of that member.
string
The server the event happened in. Not nullable: system messages are always server events.
string
The channel the event is associated with.
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.Member
One server member.string
The member’s normalized id.
string
The member’s display name.
number
Online status code, where
0 means offline.Date | null
Account creation time, not the time the member joined the server, when known.
string | null
The member’s avatar reference, or
null.number | null
The member’s subscription tier, or
null.boolean
Whether the member is a bot.
MemberRole | null
The member’s assigned role, or
null.MemberRole
A member’s assigned role, carried onMember.
string
The role’s normalized id.
string
The role’s name.
string | null
The role’s primary color, or
null.string | null
The role’s secondary color, or
null.boolean
Whether the role confers admin standing.
Role
One server role, returned byfetchRoles().
string
The role’s normalized id.
string
The role’s name.
string | null
The role’s primary color, or
null.string | null
The role’s secondary color, or
null.number | null
The role’s position in the ordering, or
null. Lower numbers sort higher.number
How many members hold the role.
BanInfo
One entry in a server’s ban list, returned byfetchBans().
string
The banned member’s normalized id.
string | null
The resolved display name, or
null when the account no longer resolves.Date | null
When the ban was recorded, when known.
string
The stored ban reason, or an empty string.
MessageLocation
The remembered location of a message the bot has seen, returned bymessageLocation().
string | null
The server the message is in, or
null for a DM. When it is null, channelId holds the dm id.string
The channel the message is in.
string
The channel’s group, where known.
string
The message author’s normalized id.
number | null
The message’s send time in milliseconds, or
null.VoiceConnection
Your bot’s own voice membership, returned byjoinVoice() and voiceConnection().
string
The LiveKit credential the backend minted, opaque to the SDK.
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.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, fromvoiceRoster() and the voiceJoin event. Eventually consistent.
boolean
True while the member’s voice session is inside the backend’s 60 second reconnect grace window.
serverMuted and serverDeafened come from a separate server-side query and are best-effort. The other flags are reliable.
BotStatus
The named presence valuessetStatus() accepts.
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 avoiceStateUpdate event.
VoiceParticipant fields above.
Guild
The payload ofguildCreate and guildDelete. A server is called a guild here, matching the discord.js naming.
BotUser
Your bot’s identity, available asclient.user after login.
string
Your bot’s normalized id. Compare it against
msg.authorId to ignore your bot’s own messages.string
Your bot’s username.
PermissionSet
The resolved capability set for one server: 31 named booleans plus a numeric rank. Returned bypermissions() and spread into the permissionsUpdate payload.
Next
Errors
Every error class an action can reject with.
Permissions
All 31 permission names.
Events
Where these types come from.
Client
The methods that return them.