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');
});

exported from lib.weeble.d

Properties

Message.attachments

type: readonly Attachment[]

Files attached to the message.

Message.author

type: readonly User | null

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

Message.channel

type: readonly MessageChannel

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

Message.channelId

type: readonly string

ID of the channel where this message was sent.

Message.content

type: readonly string

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

Message.createdAt

type: readonly Date

When this message was created.

Message.createdTimestamp

type: readonly number

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

Message.editedAt

type: readonly Date | null

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

Message.editedTimestamp

type: readonly number | null

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

Message.embeds

type: readonly Embed[]

Rich embeds in the message.

Message.flags

type: readonly number

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

Message.guildId

type: readonly string | null

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

Message.id

type: readonly string

Message ID.

Message.member

type: readonly GuildMember | null

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

Message.mentionEveryone

type: readonly boolean

Indicates whether the message mentions everyone or here.

Message.mentionRoles

type: readonly string[]

IDs of roles explicitly mentioned in the message.

Message.mentions

type: readonly User[]

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

Message.pinned

type: readonly boolean

Whether this message is pinned in its channel.

Message.poll

type: readonly Poll | null

Poll attached to this message, or null if none.

Message.reactions

type: readonly MessageReaction[]

Reactions on the message.

Message.reference

type: readonly MessageReference | null

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

Message.referencedMessage

type: readonly Message | null

The message being replied to, or null when unavailable.

Message.type

type: readonly MessageType

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

Message.url

type: readonly string

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

Message.webhookId

type: readonly 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.