Skip to content

Message

Package: @erinjs/core

Represents a message in a channel.

Constructor

NameTypeOptionalDescription
clientClientNo
dataAPIMessageNoAPI message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE

Properties

NameTypeReadonlyOptionalDescription
attachmentsCollection<string, APIMessageAttachment>YesNo
authorUserYesNo
callanyYesNo
channelDMChannel | GuildChannel | TextChannel | nullYesNoChannel where this message was sent. Resolved from cache; null if not cached.
Messages can only exist in text-based channels (text, DM, announcement), so this always has send() when non-null.
channelIdstringYesNo
clientClientYesNo
contentstringNoNo
createdAtDateYesNo
editedAtDate | nullYesNo
embedsAPIEmbed[]YesNo
flagsnumberYesNo
guildGuild | nullYesNoGuild where this message was sent. Resolved from cache; null for DMs or if not cached.
guildIdstring | nullYesNo
idstringYesNo
mentionEveryonebooleanYesNo
mentionRolesstring[]YesNoRole IDs mentioned in this message.
mentionsUser[]YesNoUsers mentioned in this message.
messageReferenceanyYesNo
messageSnapshotsAPIMessageSnapshot[]YesNo
noncestring | nullYesNoClient-side nonce for acknowledgment. Null if not provided.
pinnedbooleanNoNo
reactionsAPIMessageReaction[]YesNo
referencedMessageMessage | nullYesNo
stickersAPIMessageSticker[]YesNo
ttsbooleanYesNo
typeMessageTypeYesNo
webhookIdstring | nullYesNoWebhook ID if this message was sent via webhook. Null otherwise.

Methods

createReactionCollector()

Create a reaction collector for this message. Collects reactions matching the filter until time expires or max is reached.

Returns: ReactionCollector

Parameters:

NameTypeOptionalDescription
optionsReactionCollectorOptionsYesFilter, time (ms), and max count

delete() async

Delete this message.

Returns: Promise<void>

Parameters:

None


deleteAttachment() async

Delete a specific attachment from this message. DELETE /channels/{id}/messages/{id}/attachments/{attachmentId}.

Returns: Promise<void>

Parameters:

NameTypeOptionalDescription
attachmentIdstringNo

edit() async

Edit this message. Only the author (or admins) can edit.

Returns: Promise<Message>

Parameters:

NameTypeOptionalDescription
optionsMessageEditOptionsNoNew content and/or embeds

fetch() async

Re-fetch this message from the API to get the latest content, embeds, reactions, etc. Use when you have a stale Message (e.g. from an old event or cache) and need fresh data.

Returns: Promise<Message>

Parameters:

None


fetchReactionUsers() async

Fetch users who reacted with the given emoji.

Returns: Promise<User[]>

Parameters:

NameTypeOptionalDescription
emojistring | { name: string; id?: string; animated?: boolean; }NoUnicode emoji or custom { name, id }
options{ limit?: number; after?: string; }Yeslimit (1–100), after (user ID for pagination)

formatEmoji()

Format emoji for reaction API: unicode string or "name:id" for custom. For string resolution (e.g. :name:), use client.resolveEmoji; Message methods resolve automatically when guildId is available.

Returns: string

Parameters:

NameTypeOptionalDescription
emojistring | { name: string; id: string; }No

pin() async

Pin this message to the channel. Requires Manage Messages permission.

Returns: Promise<void>

Parameters:

None


react() async

Add a reaction to this message (as the bot).

Returns: Promise<void>

Parameters:

NameTypeOptionalDescription
emojistring | { name: string; id?: string; animated?: boolean; }NoUnicode emoji, custom { name, id }, :name:, name:id, or <:name:id>

removeAllReactions() async

Remove all reactions from this message. Requires moderator permissions.

Returns: Promise<void>

Parameters:

None


removeReaction() async

Remove the bot's reaction, or a specific user's reaction if userId is provided.

Returns: Promise<void>

Parameters:

NameTypeOptionalDescription
emojistring | { name: string; id?: string; animated?: boolean; }NoUnicode emoji, custom { name, id }, :name:, name:id, or <:name:id>
userIdstringYesIf provided, removes that user's reaction (requires moderator permissions)

removeReactionEmoji() async

Remove all reactions of a specific emoji from this message.

Returns: Promise<void>

Parameters:

NameTypeOptionalDescription
emojistring | { name: string; id?: string; animated?: boolean; }NoUnicode emoji, custom { name, id }, :name:, name:id, or <:name:id>. Requires moderator permissions.

reply() async

Reply to this message (shows as a reply in the client).

Returns: Promise<Message>

Parameters:

NameTypeOptionalDescription
optionsstring | (MessageSendOptions & ReplyOptions)NoText content or object with content, embeds, and/or reply options (ping, replyTo)
replyOptionsReplyOptionsYes

resolveChannel() async

Resolve the channel (from cache or API). Use when you need the channel and it may not be cached.

Returns: Promise<Channel>

Parameters:

None


resolveEmojiForReaction()

Returns: Promise<string>

Parameters:

NameTypeOptionalDescription
emojistring | { name: string; id?: string; animated?: boolean; }No

resolveGuild() async

Resolve the guild (from cache or API). Returns null for DMs.

Returns: Promise<Guild | null>

Parameters:

None


send() async

Send a message to this channel without replying. Use when you want a standalone message.

Returns: Promise<Message>

Parameters:

NameTypeOptionalDescription
optionsstring | MessageSendOptionsNoText content or object with content, embeds, and/or files

sendTo() async

Send a message to a specific channel. Use for logging, forwarding, or sending to another channel in the guild.

Returns: Promise<Message>

Parameters:

NameTypeOptionalDescription
channelIdstringNoSnowflake of the target channel (e.g. log channel ID)
optionsMessageSendOptionsNoText content or object with content and/or embeds

unpin() async

Unpin this message from the channel. Requires Manage Messages permission.

Returns: Promise<void>

Parameters:

None

Released under the Apache-2.0 License.