Message

Message

Represents a message

Constructor

new Message()

Properties:
Properties
Name Type Attributes Description
activity Object <nullable>

The activity specified in the message

application Object <nullable>

The application of the activity in the message

applicationID String <nullable>

The ID of the interaction's application

attachments Array.<Object>

Array of attachments

author User

The message author

call Object

The call associated with the message

Name Type Attributes Description
endedTimestamp Number <nullable>

The time when the call ended

participants Array.<String>

An array of user IDs that participated in the call

channel DMChannel | TextChannel | NewsChannel

The channel the message is in. Can be partial with only the id if the channel is not cached.

channelMentions Array.<String>

Array of mentions channels' ids

cleanContent String <nullable>

Message content with mentions replaced by names. Mentions are currently escaped, but this behavior is [DEPRECATED] and will be removed soon. Use allowed mentions, the official way of avoiding unintended mentions, when creating messages.

command Command <nullable>

The Command used in the Message, if any (CommandClient only)

components Array.<Object>

An array of component objects

content String

Message content

createdAt Number

Timestamp of message creation

editedTimestamp Number <nullable>

Timestamp of latest message edit

embeds Array.<Object>

Array of embeds

flags Number

Message flags (see constants)

guildID String <nullable>

The ID of the guild this message is in (undefined if in DMs)

id String

The ID of the message

interaction Object <nullable>

An object containing info about the interaction the message is responding to, if applicable

Properties
Name Type Attributes Description
id String

The ID of the interaction

member Member <nullable>

The member who invoked the interaction

name String

The name of the command

type Number

The type of interaction

user User

The user who invoked the interaction

jumpLink String

The url used by Discord clients to jump to this message

member Member <nullable>

The message author with server-specific data

mentionEveryone Boolean

Whether the message mentions everyone/here or not

mentions Array.<User>

Array of mentioned users

messageReference Object <nullable>

An object containing the reference to the original message if it is a crossposted message, reply or forwarded message

Properties
Name Type Attributes Description
channelID String

The ID of the channel this message was crossposted from

guildID String <nullable>

The ID of the guild this message was crossposted from

messageID String <nullable>

The ID of the original message this message was crossposted from

type Number

The type of reference. Either 0 (REPLY) or 1 (FORWARDED)

messageSnapshots Array.<Object> <nullable>

The message associated with the messageReference

Properties
Name Type Attributes Description
guildID String <nullable>

The ID of the guild this message originated from

message Message

Subset of message fields. The list of message fields subset consists of: attachments, content, edited_timestamp, embeds, flags, id, mentions, roleMentions, timestamp and type

pinned Boolean

Whether the message is pinned or not

poll Object <nullable>

A poll object. See the official Discord API documentation entry for object structure. Note: poll.expiry is an int, not ISO8601 as mentioned in Discord docs

prefix String <nullable>

The prefix used in the Message, if any (CommandClient only)

reactions Object

An object containing the reactions on the message. Each key is a reaction emoji and each value is an object with properties burst_colors (Array), count (Number), count_details (an object with burst and normal keys corresponding to the amount of reactions), me (Boolean) and me_burst for that specific reaction emoji.

referencedMessage Message <nullable>

The message that was replied to. If undefined, message data was not received. If null, the message was deleted.

roleMentions Array.<String>

Array of mentioned roles' ids

roleSubscriptionData Object <nullable>

An object containing the data of the role subscription purchase or renewal that prompted this ROLE_SUBSCRIPTION_PURCHASE message. See the official Discord API documentation entry for object structure

stickers Array.<Object> <nullable>

[DEPRECATED] The stickers sent with the message

stickerItems Array.<Object> <nullable>

The stickers sent with the message

timestamp Number

Timestamp of message creation

tts Boolean

Whether to play the message using TTS or not

type Number

The type of the message

webhookID String <nullable>

ID of the webhook that sent the message

Source:

Methods

addReaction(reaction) → {Promise}

Add a reaction to a message

Source:
Parameters:
Name Type Description
reaction String

The reaction (Unicode string if Unicode emoji, emojiName:emojiID if custom emoji)

Returns:
Type:
Promise

createThreadWithMessage(options) → {Promise.<(NewsThreadChannel|PublicThreadChannel)>}

Create a thread with this message

Source:
Parameters:
Name Type Description
options Object

The thread options

Name Type Attributes Description
autoArchiveDuration Number <optional>

Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080

name String

The thread channel name

rateLimitPerUser Number <optional>

The time in seconds a user has to wait before sending another message (0-21600) (does not affect bots or users with manageMessages/manageChannel permissions)

reason String <optional>

The reason to be displayed in audit logs

Returns:
Type:
Promise.<(NewsThreadChannel|PublicThreadChannel)>

crosspost() → {Promise.<Message>}

Crosspost (publish) a message to subscribed channels (NewsChannel only)

Source:
Returns:
Type:
Promise.<Message>

delete(reasonopt) → {Promise}

Delete the message

Source:
Parameters:
Name Type Attributes Description
reason String <optional>

The reason to be displayed in audit logs

Returns:
Type:
Promise

deleteWebhook(token) → {Promise}

Delete the message as a webhook

Source:
Parameters:
Name Type Description
token String

The token of the webhook

Returns:
Type:
Promise

edit(content) → {Promise.<Message>}

Edit the message

Source:
Parameters:
Name Type Description
content String | Array | Object

A string, array of strings, or object. If an object is passed:

Name Type Attributes Description
allowedMentions Object <optional>

A list of mentions to allow (overrides default)

Name Type Attributes Description
everyone Boolean <optional>

Whether or not to allow @everyone/@here

roles Boolean | Array.<String> <optional>

Whether or not to allow all role mentions, or an array of specific role mentions to allow

users Boolean | Array.<String> <optional>

Whether or not to allow all user mentions, or an array of specific user mentions to allow

attachments Array.<Object> <optional>

An array of attachment objects that will be appended to the message, including new files. Only the provided files will be appended

Name Type Attributes Description
description String <optional>

The description of the file

filename String <optional>

The name of the file. This is not required if you are attaching a new file

id Number | String

The ID of the file. If you are attaching a new file, this would be the index of the file

components Array.<Object> <optional>

An array of component objects

Name Type Attributes Description
custom_id String <optional>

The ID of the component (type 2 style 0-4 and type 3,5,6,7,8 only)

disabled Boolean <optional>

Whether the component is disabled (type 2 and 3,5,6,7,8 only)

emoji Object <optional>

The emoji to be displayed in the component (type 2)

label String <optional>

The label to be displayed in the component (type 2)

default_values Array.<Object> <optional>

default values for the component (type 5,6,7,8 only)

Name Type Attributes Description
id String <optional>

id of a user, role, or channel

type String <optional>

type of value that id represents (user, role, or channel)

max_values Number <optional>

The maximum number of items that can be chosen (1-25, default 1)

min_values Number <optional>

The minimum number of items that must be chosen (0-25, default 1)

options Array.<Object> <optional>

The options for this component (type 3 only)

Name Type Attributes Description
default Boolean <optional>

Whether this option should be the default value selected

description String <optional>

The description for this option

emoji Object <optional>

The emoji to be displayed in this option

label String

The label for this option

value Number | String

The value for this option

placeholder String <optional>

The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)

style Number <optional>

The style of the component (type 2 only) - If 0-4, custom_id is required; if 5, url is required

type Number

The type of component - If 1, it is a collection and a components array (nested) is required; if 2, it is a button; if 3, it is a string select; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select

url String <optional>

The URL that the component should open for users (type 2 style 5 only)

content String <optional>

A content string

embed Object <optional>

[DEPRECATED] An embed object. See the official Discord API documentation entry for object structure

embeds Array.<Object> <optional>

An array of embed objects. See the official Discord API documentation entry for object structure

file Object | Array.<Object> <optional>

A file object (or an Array of them)

Name Type Description
file Buffer

A buffer containing file data

name String

What to name the file

flags Number <optional>

A number representing the flags to apply to the message. See the official Discord API documentation entry for flags reference

Returns:
Type:
Promise.<Message>

editWebhook(token, options) → {Promise.<Message>}

Edit the message as a webhook

Source:
Parameters:
Name Type Description
token String

The token of the webhook

options Object

Webhook message edit options

Name Type Attributes Description
allowedMentions Object <optional>

A list of mentions to allow (overrides default)

Name Type Attributes Description
everyone Boolean <optional>

Whether or not to allow @everyone/@here

repliedUser Boolean <optional>

Whether or not to mention the author of the message being replied to

roles Boolean | Array.<String> <optional>

Whether or not to allow all role mentions, or an array of specific role mentions to allow

users Boolean | Array.<String> <optional>

Whether or not to allow all user mentions, or an array of specific user mentions to allow

attachments Array.<Object> <optional>

An array of attachment objects that will be appended to the message, including new files. Only the provided files will be appended

Name Type Attributes Description
description String <optional>

The description of the file

filename String <optional>

The name of the file. This is not required if you are attaching a new file

id Number | String

The ID of the file. If you are attaching a new file, this would be the index of the file

components Array.<Object> <optional>

An array of component objects

Name Type Attributes Description
custom_id String <optional>

The ID of the component (type 2 style 0-4 and type 3,5,6,7,8 only)

disabled Boolean <optional>

Whether the component is disabled (type 2 and type 3,5,6,7,8 only)

emoji Object <optional>

The emoji to be displayed in the component (type 2)

label String <optional>

The label to be displayed in the component (type 2)

default_values Array.<Object> <optional>

default values for the component (type 5,6,7,8 only)

Name Type Attributes Description
id String <optional>

id of a user, role, or channel

type String <optional>

type of value that id represents (user, role, or channel)

max_values Number <optional>

The maximum number of items that can be chosen (1-25, default 1)

min_values Number <optional>

The minimum number of items that must be chosen (0-25, default 1)

options Array.<Object> <optional>

The options for this component (type 3 only)

Name Type Attributes Description
default Boolean <optional>

Whether this option should be the default value selected

description String <optional>

The description for this option

emoji Object <optional>

The emoji to be displayed in this option

label String

The label for this option

value Number | String

The value for this option

placeholder String <optional>

The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)

style Number <optional>

The style of the component (type 2 only) - If 0-4, custom_id is required; if 5, url is required

type Number

The type of component - If 1, it is a collection and a components array (nested) is required; if 2, it is a button; if 3, it is a string select; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select

url String <optional>

The URL that the component should open for users (type 2 style 5 only)

content String <optional>

A content string

embed Object <optional>

[DEPRECATED] An embed object. See the official Discord API documentation entry for object structure

embeds Array.<Object> <optional>

An array of embed objects. See the official Discord API documentation entry for object structure

file Object | Array.<Object> <optional>

A file object (or an Array of them)

Name Type Description
file Buffer

A buffer containing file data

name String

What to name the file

Returns:
Type:
Promise.<Message>

getReaction(reaction, optionsopt, beforeopt, afteropt) → {Promise.<Array.<User>>}

Get a list of users who reacted with a specific reaction

Source:
Parameters:
Name Type Attributes Description
reaction String

The reaction (Unicode string if Unicode emoji, emojiName:emojiID if custom emoji)

options Object <optional>

Options for the request. If this is a number, it is treated as options.limit ([DEPRECATED] behavior)

Name Type Attributes Default Description
after String <optional>

Get users after this user ID

limit Number <optional>
100

The maximum number of users to get

type Number <optional>
0

The type of reaction (0 for normal, 1 for burst)

before String <optional>

[DEPRECATED] Get users before this user ID. Discord no longer supports this parameter

after String <optional>

[DEPRECATED] Get users after this user ID

Returns:
Type:
Promise.<Array.<User>>

pin() → {Promise}

Pin the message

Source:
Returns:
Type:
Promise

removeReaction(reaction, userIDopt) → {Promise}

Remove a reaction from a message

Source:
Parameters:
Name Type Attributes Default Description
reaction String

The reaction (Unicode string if Unicode emoji, emojiName:emojiID if custom emoji)

userID String <optional>
"@me"

The ID of the user to remove the reaction for

Returns:
Type:
Promise

removeReactionEmoji(reaction) → {Promise}

Remove all reactions from a message for a single emoji

Source:
Parameters:
Name Type Description
reaction String

The reaction (Unicode string if Unicode emoji, emojiName:emojiID if custom emoji)

Returns:
Type:
Promise

removeReactions() → {Promise}

Remove all reactions from a message

Source:
Returns:
Type:
Promise

unpin() → {Promise}

Unpin the message

Source:
Returns:
Type:
Promise