Appearance
Message
Package: @erinjs/core
Represents a message in a channel.
Constructor
| Name | Type | Optional | Description |
|---|---|---|---|
client | Client | No | |
data | APIMessage | No | API message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE |
Properties
| Name | Type | Readonly | Optional | Description |
|---|---|---|---|---|
attachments | Collection<string, APIMessageAttachment> | Yes | No | |
author | User | Yes | No | |
call | any | Yes | No | |
channel | DMChannel | GuildChannel | TextChannel | null | Yes | No | Channel 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. | ||||
channelId | string | Yes | No | |
client | Client | Yes | No | |
content | string | No | No | |
createdAt | Date | Yes | No | |
editedAt | Date | null | Yes | No | |
embeds | APIEmbed[] | Yes | No | |
flags | number | Yes | No | |
guild | Guild | null | Yes | No | Guild where this message was sent. Resolved from cache; null for DMs or if not cached. |
guildId | string | null | Yes | No | |
id | string | Yes | No | |
mentionEveryone | boolean | Yes | No | |
mentionRoles | string[] | Yes | No | Role IDs mentioned in this message. |
mentions | User[] | Yes | No | Users mentioned in this message. |
messageReference | any | Yes | No | |
messageSnapshots | APIMessageSnapshot[] | Yes | No | |
nonce | string | null | Yes | No | Client-side nonce for acknowledgment. Null if not provided. |
pinned | boolean | No | No | |
reactions | APIMessageReaction[] | Yes | No | |
referencedMessage | Message | null | Yes | No | |
stickers | APIMessageSticker[] | Yes | No | |
tts | boolean | Yes | No | |
type | MessageType | Yes | No | |
webhookId | string | null | Yes | No | Webhook 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:
| Name | Type | Optional | Description |
|---|---|---|---|
options | ReactionCollectorOptions | Yes | Filter, 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:
| Name | Type | Optional | Description |
|---|---|---|---|
attachmentId | string | No |
edit() async
Edit this message. Only the author (or admins) can edit.
Returns: Promise<Message>
Parameters:
| Name | Type | Optional | Description |
|---|---|---|---|
options | MessageEditOptions | No | New 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:
| Name | Type | Optional | Description |
|---|---|---|---|
emoji | string | { name: string; id?: string; animated?: boolean; } | No | Unicode emoji or custom { name, id } |
options | { limit?: number; after?: string; } | Yes | limit (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:
| Name | Type | Optional | Description |
|---|---|---|---|
emoji | string | { 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:
| Name | Type | Optional | Description |
|---|---|---|---|
emoji | string | { name: string; id?: string; animated?: boolean; } | No | Unicode 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:
| Name | Type | Optional | Description |
|---|---|---|---|
emoji | string | { name: string; id?: string; animated?: boolean; } | No | Unicode emoji, custom { name, id }, :name:, name:id, or <:name:id> |
userId | string | Yes | If 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:
| Name | Type | Optional | Description |
|---|---|---|---|
emoji | string | { name: string; id?: string; animated?: boolean; } | No | Unicode 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:
| Name | Type | Optional | Description |
|---|---|---|---|
options | string | (MessageSendOptions & ReplyOptions) | No | Text content or object with content, embeds, and/or reply options (ping, replyTo) |
replyOptions | ReplyOptions | Yes |
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:
| Name | Type | Optional | Description |
|---|---|---|---|
emoji | string | { 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:
| Name | Type | Optional | Description |
|---|---|---|---|
options | string | MessageSendOptions | No | Text 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:
| Name | Type | Optional | Description |
|---|---|---|---|
channelId | string | No | Snowflake of the target channel (e.g. log channel ID) |
options | MessageSendOptions | No | Text 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