Skip to main content
A Message is a message sent in a channel. You get one from the events about messages, from what send() and reply() return, and from fetchMessage() and fetchMessages() on a channel.
How to send, edit and read messages is in Sending messages; everything reply() and edit() accept is in Message options.
content, embeds and attachments are empty for the messages of other people unless the Message Content Intent is enabled for your bot. Messages that mention the bot, and private messages, always have their content.

Properties

Snowflake
The unique id Discord gave it.
Date
When it was created: a Discord id contains its creation date.
User
Who wrote the message.
readonly User[]
The users mentioned in the message.
Snowflake
The id of the channel of the message.
Snowflake | null
The id of the server; null for a private message.
TextBasedChannel | null
The channel of the message, when it is known.
Guild | null
The server of the message; null for a private message.
GuildMember | null
The author as a member of the server, when it is known.
string
The text of the message. Empty when the bot is not allowed to read it: reading the messages of others needs the Message Content intent.
MessageType
The kind of message, as a value of MessageType (a regular one, a reply, a join notice…).
Date | null
When the message was last edited; null when it never was.
boolean
Whether the message is pinned.
boolean
Whether the message was read aloud.
Embed[]
The embeds of the message. Each entry is an Embed.
Attachment[]
The files attached to the message. Each entry is an Attachment.
Reaction[]
The reactions on the message, one entry per emoji. Each entry is a Reaction.
boolean
Whether the message mentions @everyone or @here.
readonly Snowflake[]
The ids of the roles mentioned in the message.
MessageFlagName[]
The flags of the message, by name (Ephemeral, SuppressEmbeds…).
Snowflake | null
The id of the webhook that sent the message, when one did.
Snowflake | null
The id of the message this one replies to, when it is a reply.
boolean
Whether a person wrote it: not a bot, a webhook or Discord itself.
string
The link that opens the message in Discord.

Helpers

These read what the bot already knows: they never send a request.

toJSON()

The data of Discord as a plain object, with camelCase names.

Reading from Discord

fetch()

Asks Discord for the latest version of the message. Discord documentation

fetchReactionUsers()

The users who reacted with an emoji (100 at most per call). Discord documentation

Actions

reply()

Answers the message, in the same channel. What it accepts is a MessageInput. Discord documentation

edit()

Changes the message. Only the content, embeds, components and files of a message the bot wrote can change. The options are a MessageEditOptions. Discord documentation

delete()

Deletes the message. Discord documentation

react()

Adds a reaction of the bot to the message. Discord documentation

removeReaction()

Removes a reaction: of the bot, or of the given user. Discord documentation

clearReactions()

Removes every reaction of the message, or every reaction of one emoji. Discord documentation

pin()

Pins the message in its channel. Discord documentation

unpin()

Unpins the message. Discord documentation

crosspost()

Publishes a message of an announcement channel to the servers that follow it. Discord documentation

startThread()

Starts a thread from the message.
string
required
The name of the thread, 1 to 100 characters.
number
After how many minutes without activity the thread leaves the channel list: 60, 1440, 4320 or 10080.
number | null
How many seconds a member waits between two messages (0 to 21600).
Discord documentation

Waiting

They wait for what comes next on the message, while your bot runs: a restart ends the wait. How to use them is in the guide.

waitForClick()

Waits for a click on a button or a menu of this message: of a person (from), anyone by default. Resolves with the click, to answer with click.interaction, or null when within (one minute by default) passed first. A click taken here does not run the run of the button; a button that is only waited for needs none. A restart of the bot ends the wait.

waitForReaction()

Waits for a reaction added to this message: of a person (from), anyone’s but a bot’s by default, with an emoji (emoji), any by default. Resolves with it, or null when within (one minute by default) passed first. A restart of the bot ends the wait.

Types

GuildMessage

A message of a server: its server is known. It is what the events about messages give for what happens in a server.
Snowflake
The id of the server.
Guild
The server of the message.
GuildTextBasedChannel
The channel of the message.

MemberMessage

A message written in a server by one of its members: neither a private message nor the message of a webhook. It is what the events about messages give by default. It has everything of GuildMessage, and:
GuildMember
The author as a member of the server.

PrivateMessage

A private message, for a file that receives both kinds ({ where: 'both' }): there is no server, which is how it is told apart from a GuildMessage.
null
No server: it is a private message.
null
No server: it is a private message.
null
No member: the author is author.
DMChannel | null
The private conversation, when the bot knows it.

DmMessage

A private message, for a file that only receives those ({ where: 'dm' }): nothing about a server exists on it. guildId, guild and member are not even offered by your editor.
DMChannel | null
The private conversation, when the bot knows it.
You only need these names to type a function of your own:

EmojiInput

An emoji to react with: a standard one ("👍"), or a custom one. The methods that take one accept:
  • a standard emoji: '👍'
  • a custom emoji as Discord writes it: '<:name:123456789012345678>' (or '<a:name:…>' when animated)
  • a custom emoji as an object: { id: '123456789012345678', name: 'name' }, or a GuildEmoji
An empty text is refused before anything is sent:

MessageFlagName

The name of a flag of a message: a key of MessageFlags. It is what flags lists.

WaitForClickOptions

What waitForClick() takes.
PersonInput
Only a click of this person. Anyone by default. A PersonInput.
Duration
How long to wait: '30s', '2m'. One minute by default.

Click

A click on a button or a menu of a message, as waitForClick() gives it.
ComponentInteraction
The click itself: answer it as in the run of a button, with update(), reply() or deferUpdate(). Without an answer within 2 seconds, the bot changes nothing on screen for you (deferUpdate()).
User
Who clicked.
GuildMember | null
Who clicked, as a member of the server; null in a private message.
string
The name of the button or menu: the name of its export.
Readonly<Record<string, string | number | boolean>>
The data the button or menu carries.
readonly string[]
What was picked in a menu: the values of a menu of texts, the ids of the people, roles or channels of the others. Empty for a button.
(component: ButtonDeclaration<never> | SelectDeclaration<never>) => boolean
Whether it is this button or this menu.

WaitForReactionOptions

What waitForReaction() takes.
PersonInput
Only a reaction of this person. Anyone but a bot by default.
string
Only this emoji: a standard one ('👍'), or a custom one by its name, its id or as Discord writes it ('<:party:123>').
Duration
How long to wait: '30s', '2m'. One minute by default.

WaitedReaction

A reaction added to a message, as waitForReaction() gives it.
ReactionEmoji
The emoji.
User
Who reacted.
GuildMember | null
Who reacted, as a member of the server; null in a private message.

Elsewhere