Class

Message

A message in a channel.

Extends Base

Constructor

new Message(client: Client, data: APIMessage)

Construct a message from API data.

ParamTypeDescription
clientClient
dataAPIMessage

API message from REST or MESSAGE_CREATE

Properties

attachments: Collection<string, APIMessageAttachment> (readonly)

Attached files (images, videos, etc.).

author: User (readonly)

The user who sent this message.

call: APIMessageCall | null (readonly)

Call data if this message represents a call event.

channel: (TextChannel | DMChannel | GuildChannel) | null (readonly)

Cached text/DM/guild channel, or null if uncached.

channelId: string (readonly)

Channel ID where this message was sent.

client: Client (readonly)

The Client that instantiated this message.

content: string

Text content of the message.

createdAt: Date (readonly)

When the message was created.

editedAt: Date | null (readonly)

When the message was last edited, or null if never edited.

embeds: APIEmbed[] (readonly)

Embedded content (rich previews, etc.).

flags: number (readonly)

Message flags bitfield.

guild: Guild | null (readonly)

Cached guild, or null for DMs / uncached.

guildId: string | null (readonly)

Guild ID if in a guild channel, null for DMs.

id: string (readonly)

Snowflake ID of this message.

mentionEveryone: boolean (readonly)

Whether `@everyone` or `@here` was mentioned.

mentionRoles: string[] (readonly)

Role IDs mentioned in the message.

mentions: User[] (readonly)

Users mentioned in the message.

messageReference: APIMessageReference | null (readonly)

Reference to a replied-to message, if any.

messageSnapshots: APIMessageSnapshot[] (readonly)

Message snapshots for forwarded messages.

nonce: string | null (readonly)

Client-side nonce for deduplication.

pinned: boolean

Whether the message is pinned.

reactions: APIMessageReaction[] (readonly)

Reactions on the message.

referencedMessage: Message | null (readonly)

The full referenced (replied-to) message, or null.

stickers: APIMessageSticker[] (readonly)

Stickers sent with the message.

tts: boolean (readonly)

Whether this is a text-to-speech message.

type: MessageType (readonly)

Message type (Default, Reply, etc.).

webhookId: string | null (readonly)

Webhook ID if sent by a webhook.

Methods

createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector

Create a ReactionCollector for this message.

ParamTypeDescription
options?ReactionCollectorOptions
delete(): Promise<void>

Delete this message.

deleteAttachment(attachmentId: string): Promise<void>

Delete a specific attachment from this message.

ParamTypeDescription
attachmentIdstring
edit(options: MessageEditOptions): Promise<Message>

Edit this message (requires author or admin permissions).

ParamTypeDescription
optionsMessageEditOptions
fetch(): Promise<Message>

Fetch the latest version of this message from the API.

fetchReactionUsers(emoji: EmojiInput, options?: { limit?: number; after?: string; }): Promise<User[]>

Fetch users who reacted with a specific emoji.

ParamTypeDescription
emojiEmojiInput
options?{ limit?: number; after?: string; }
fetchReactionUsersPage(emoji: EmojiInput, options?: { limit?: number; after?: string; }): Promise<{ users: User[]; hasMore: boolean; nextAfter: string | null }>

Fetch reaction users with pagination metadata.

ParamTypeDescription
emojiEmojiInput
options?{ limit?: number; after?: string; }
pin(): Promise<void>

Pin this message in the channel.

react(emoji: EmojiInput): Promise<void>

React to this message with an emoji.

ParamTypeDescription
emojiEmojiInput
removeAllReactions(): Promise<void>

Remove all reactions from this message.

removeReaction(emoji: EmojiInput, userId?: string): Promise<void>

Remove a reaction (bot's own or a user's if ID is provided).

ParamTypeDescription
emojiEmojiInput
userId?string
removeReactionEmoji(emoji: EmojiInput): Promise<void>

Remove all reactions of a specific emoji.

ParamTypeDescription
emojiEmojiInput
reply(options: string | (MessageSendOptions & ReplyOptions), replyOptions?: ReplyOptions): Promise<Message>

Reply to this message.

ParamTypeDescription
optionsstring | (MessageSendOptions & ReplyOptions)
replyOptions?ReplyOptions
resolveChannel(): Promise<Channel>

Fetch and resolve the channel this message is in.

resolveGuild(): Promise<Guild | null>

Fetch and resolve the guild, or null if a DM.

send(options: MessagePrepareInput): Promise<Message>

Send a message in this channel without replying.

ParamTypeDescription
optionsMessagePrepareInput
sendTo(channelId: string, options: MessagePrepareInput): Promise<Message>

Send a message to another channel by ID.

ParamTypeDescription
channelIdstring
optionsMessagePrepareInput
unpin(): Promise<void>

Unpin this message from the channel.