Message

class Message

A message snapshot received from Discord or returned by a REST request. Event objects are not live views. Call Message.fetch when a handler needs the newest state.

Example

discord.on(discord.events.MESSAGE_CREATE, async (message) => {
  if (!message.author || message.author.bot || message.content !== '!ping') return;
  await message.reply('pong');
});

Properties

Property

Type

Description

attachments

Attachment[]

Files attached to the message.

author

User | null

User or webhook identity that sent the message, or null when Discord omits the author from a partial message payload.

channel

MessageChannel

Lightweight channel handle. Use it to send without fetching the full channel first, for example await message.channel.send("Hello").

channelId

string

ID of the channel where this message was sent.

content

string

Raw message content. In guilds this may be empty unless the bot has the privileged Message Content intent or Discord grants an exception.

createdAt

Date

When this message was created.

createdTimestamp

number

Timestamp derived from the Discord snowflake ID, in milliseconds since epoch.

editedAt

Date | null

When this message was last edited, or null if it has not been edited.

editedTimestamp

number | null

Edited timestamp in milliseconds since epoch, or null if never edited.

embeds

Embed[]

Rich embeds in the message.

flags

number

Bitmask of message flags. Zero means no flags are set.

guildId

string | null

ID of the guild this message was sent in, or null when Discord omits it.

id

string

Message ID.

member

GuildMember | null

The guild member who sent the message, or null if not in a guild.

mentionEveryone

boolean

Indicates whether the message mentions everyone or here.

mentionRoles

string[]

IDs of roles explicitly mentioned in the message.

mentions

User[]

User objects explicitly mentioned in the message content. This array does not include users mentioned only inside embeds or components.

pinned

boolean

Whether this message is pinned in its channel.

poll

Poll | null

Poll attached to this message, or null if none.

reactions

MessageReaction[]

Reactions on the message.

reference

MessageReference | null

Reference to a replied-to or crossposted message, or null.

referencedMessage

Message | null

The message being replied to, or null when unavailable.

type

MessageType

The type of message (system message, reply, etc.).

url

string

A URL that can be used to jump to this message in Discord.

webhookId

string | null

ID of the webhook that sent this message, or null if sent by a user.

Methods

async Message.clearReactions(emoji: string) → Promise<void>

Remove all reactions for a specific emoji, or all reactions if no emoji is given.

Parameters:
  • emoji: Emoji string to clear, or omit to clear all reactions.

async Message.createThread(options: ThreadFromMessageCreateOptions) → Promise<ThreadChannel>

Create a thread from this message.

Parameters:
  • options: Thread options including name, auto-archive duration, and slowmode.

Returns:

The created thread channel.

async Message.crosspost() → Promise<Message>

Crosspost (publish) this message to followed channels. Only valid in announcement channels.

Returns:

The published message.

async Message.delete(reason: string) → Promise<void>

Delete this message.

Parameters:
  • reason: Audit-log reason for deleting the message.

async Message.edit(content: string | EditMessageOptions) → Promise<Message>

Edit this message with new content or options.

Parameters:
  • content: New message body as a string, or an options object with embeds, components, etc.

Returns:

The updated message.

async Message.endPoll() → Promise<Message>

End the poll on this message early and publish results.

Returns:

The updated message with finalized poll results.

async Message.fetch() → Promise<Message>

Requests the latest version of this message from Discord. Use this when the event snapshot may be stale after edits, reactions, or poll updates.

Returns:

The updated message.

async Message.fetchChannel() → Promise<TextChannel>

Fetch the channel this message was sent in from Discord.

async Message.fetchGuild() → Promise<Guild | null>

Fetch the guild, or return null when Discord omitted the guild ID.

Returns:

The guild, or null if this message was not sent in a guild.

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

Fetch users who reacted to this message with a specific emoji.

Parameters:
  • emoji: Emoji string (for example "🔥" or "name:id" for a custom emoji).

  • options: Optional pagination. Discord returns up to 100 users per request.

Returns:

Array of users who reacted with that emoji.

async Message.forward(channelId: string) → Promise<Message>

Forward this message’s content and embeds to another channel.

Parameters:
  • channelId: The ID of the channel to forward to.

Returns:

The sent message in the target channel.

async Message.pin(reason: string) → Promise<void>

Pin this message to the channel.

Parameters:
  • reason: Audit-log reason for pinning the message.

async Message.react(emoji: string) → Promise<void>

Add a reaction to this message using a Discord emoji string.

Parameters:
  • emoji: Emoji string (e.g. "🔥" for unicode or "custom:123" for custom emoji).

async Message.removeAllReactions() → Promise<void>

Remove all reactions from this message.

async Message.removeReaction(emoji: string, userId: string) → Promise<void>

Remove another user’s reaction from this message.

Parameters:
  • emoji: The emoji string identifying the reaction.

  • userId: The ID of the user whose reaction to remove.

async Message.reply(content: string | SendMessageOptions) → Promise<Message>

Reply to this message with text or full message options. The returned message is the newly created reply, not this source message.

Parameters:
  • content: Message body as a string, or a full options object for embeds, files, etc.

Returns:

The sent message.

async Message.unpin(reason: string) → Promise<void>

Unpin this message from the channel.

Parameters:
  • reason: Audit-log reason for unpinning the message.

async Message.unreact(emoji: string) → Promise<void>

Remove your bot’s reaction by emoji.

Parameters:
  • emoji: The emoji string identifying the reaction to remove.