Class

Message

A message in a channel.

Extends Base

Constructor

Construct a message from API data.

new Message(client: Client, data: APIMessage)
client
Client
data
APIMessageAPI message from REST or MESSAGE_CREATE

Properties

NameTypeDescription
attachmentsread-onlyCollection<string, APIMessageAttachment>Attached files (images, videos, etc.).
authorread-onlyUserThe user who sent this message.
callread-onlyAPIMessageCall | nullCall data if this message represents a call event.
channelread-only(TextChannel | DMChannel | GuildChannel) | nullCached text/DM/guild channel, or null if uncached.
channelIdread-onlystringChannel ID where this message was sent.
clientread-onlyClientThe Client that instantiated this message.
contentstringText content of the message.
createdAtread-onlyDateWhen the message was created.
editedAtread-onlyDate | nullWhen the message was last edited, or null if never edited.
embedsread-onlyAPIEmbed[]Embedded content (rich previews, etc.).
flagsread-onlynumberMessage flags bitfield.
guildread-onlyGuild | nullCached guild, or null for DMs / uncached.
guildIdread-onlystring | nullGuild ID if in a guild channel, null for DMs.
idread-onlystringSnowflake ID of this message.
mentionEveryoneread-onlybooleanWhether @everyone or @here was mentioned.
mentionRolesread-onlystring[]Role IDs mentioned in the message.
mentionsread-onlyUser[]Users mentioned in the message.
messageReferenceread-onlyAPIMessageReference | nullReference to a replied-to message, if any.
messageSnapshotsread-onlyAPIMessageSnapshot[]Message snapshots for forwarded messages.
nonceread-onlystring | nullClient-side nonce for deduplication.
pinnedbooleanWhether the message is pinned.
reactionsread-onlyAPIMessageReaction[]Reactions on the message.
referencedMessageread-onlyMessage | nullThe full referenced (replied-to) message, or null.
stickersread-onlyAPIMessageSticker[]Stickers sent with the message.
ttsread-onlybooleanWhether this is a text-to-speech message.
typeread-onlyMessageTypeMessage type (Default, Reply, etc.).
webhookIdread-onlystring | nullWebhook ID if sent by a webhook.

Methods

.delete()

→ Promise<void>

Delete this message.

await message.delete();

.deleteAttachment(attachmentId)

attachmentId: string → Promise<void>

Delete a specific attachment from this message.

await message.deleteAttachment(attachmentId);

.fetch()

→ Promise<Message>

Fetch the latest version of this message from the API.

await message.fetch();

.fetchReactionUsers(emoji, options?)

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

Fetch users who reacted with a specific emoji.

await message.fetchReactionUsers(emoji);

.fetchReactionUsersPage(emoji, options?)

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

Fetch reaction users with pagination metadata.

await message.fetchReactionUsersPage(emoji);

.pin()

→ Promise<void>

Pin this message in the channel.

await message.pin();

.react(emoji)

emoji: EmojiInput → Promise<void>

React to this message with an emoji.

await message.react(emoji);

.removeAllReactions()

→ Promise<void>

Remove all reactions from this message.

await message.removeAllReactions();

.removeReaction(emoji, userId?)

emoji: EmojiInput, userId?: string → Promise<void>

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

await message.removeReaction(emoji);

.removeReactionEmoji(emoji)

emoji: EmojiInput → Promise<void>

Remove all reactions of a specific emoji.

await message.removeReactionEmoji(emoji);

.resolveGuild()

→ Promise<Guild | null>

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

await message.resolveGuild();

.unpin()

→ Promise<void>

Unpin this message from the channel.

await message.unpin();