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
attachmentsFiles attached to the message.
User or webhook identity that sent the message, or
nullwhen Discord omits the author from a partial message payload.channelLightweight channel handle. Use it to send without fetching the full channel first, for example
await message.channel.send("Hello").channelIdID of the channel where this message was sent.
contentRaw message content. In guilds this may be empty unless the bot has the privileged Message Content intent or Discord grants an exception.
createdAtWhen this message was created.
createdTimestampTimestamp derived from the Discord snowflake ID, in milliseconds since epoch.
editedAtWhen this message was last edited, or
nullif it has not been edited.editedTimestampEdited timestamp in milliseconds since epoch, or
nullif never edited.embedsEmbed[]Rich embeds in the message.
flagsBitmask of message flags. Zero means no flags are set.
guildIdID of the guild this message was sent in, or
nullwhen Discord omits it.idMessage ID.
memberThe guild member who sent the message, or
nullif not in a guild.mentionEveryoneIndicates whether the message mentions everyone or here.
mentionRolesstring[]
IDs of roles explicitly mentioned in the message.
mentionsUser[]User objects explicitly mentioned in the message content. This array does not include users mentioned only inside embeds or components.
pinnedWhether this message is pinned in its channel.
pollPoll attached to this message, or
nullif none.reactionsReactions on the message.
referenceReference to a replied-to or crossposted message, or
null.referencedMessageThe message being replied to, or
nullwhen unavailable.typeThe type of message (system message, reply, etc.).
urlA URL that can be used to jump to this message in Discord.
webhookIdID of the webhook that sent this message, or
nullif 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
nullwhen Discord omitted the guild ID.- Returns:
The guild, or
nullif 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.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.