-
Notifications
You must be signed in to change notification settings - Fork 144
Message
extends Snowflake
Represents a text message sent in a Discord text channel. Messages can contain simple content strings, rich embeds, attachments, or reactions.
Instances of this class should not be constructed by users.
Properties Inherited From Snowflake
Name | Type | Description |
---|---|---|
client | Client | A shortcut to the client object to which this container is visible. |
createdAt | number | The Unix time in seconds at which this object was created by Discord. Additional decimal points may be present, though only the first 3 (milliseconds) should be considered accurate. Equivalent to Date.parseSnowflake(Snowflake.id) . |
id | string | The Snowflake ID that can be used to identify the object. This is guaranteed to be unique except in cases where an object shares the ID of its parent. |
parent | Container/Client | The parent object of to which this container is a child. For example, the parent of a role is the guild in which the role exists. |
timestamp | string | The date and time at which this object was created by Discord, represented as an ISO 8601 string plus microseconds when available. Equivalent to Date.fromSnowflake(Snowflake.id):toISO() . |
Name | Type | Description |
---|---|---|
attachment | table/nil | A raw data table that represents the first file attachment that exists in this message. See the Discord documentation for more information. |
attachments | table | A raw data table that contains all attachments that exist for this message. If there are none, this table will not be present. |
author | User | The object of the user that created the message. |
channel | TextChannel | The channel in which this message was sent. |
cleanContent | string | The message content with all recognized mentions replaced by names and with @everyone and @here mentions escaped by a zero-width space (ZWSP). |
content | string | The raw message content. This should be between 0 and 2000 characters in length. |
editedTimestamp | string/nil | The date and time at which the message was most recently edited, represented as an ISO 8601 string plus microseconds when available. |
embed | table/nil | A raw data table that represents the first rich embed that exists in this message. See the Discord documentation for more information. |
embeds | table | A raw data table that contains all embeds that exist for this message. If there are none, this table will not be present. |
guild | Guild/nil | The guild in which this message was sent. This will not exist if the message was not sent in a guild text channel. Equivalent to Message.channel.guild . |
link | string | URL that can be used to jump-to the message in the Discord client. |
member | Member/nil | The member object of the message's author. This will not exist if the message is not sent in a guild text channel or if the member object is not cached. Equivalent to Message.guild.members:get(Message.author.id) . |
mentionedChannels | ArrayIterable | An iterable array of all known channels that are mentioned in this message. If the client does not have the channel cached, then it will not appear here. |
mentionedEmojis | ArrayIterable | An iterable array of all known emojis that are mentioned in this message. If the client does not have the emoji cached, then it will not appear here. |
mentionedRoles | ArrayIterable | An iterable array of known roles that are mentioned in this message, excluding the default everyone role. The message must be in a guild text channel and the roles must be cached in that channel's guild for them to appear here. |
mentionedUsers | ArrayIterable | An iterable array of all users that are mentioned in this message. |
mentionsEveryone | boolean | Whether this message mentions @everyone or @here. |
nonce | string/number/boolean/nil | Used by the official Discord client to detect the success of a sent message. |
oldContent | table/nil | Yields a table containing keys as timestamps and value as content of the message at that time. |
pinned | boolean | Whether this message belongs to its channel's pinned messages. |
reactions | Cache | An iterable cache of all reactions that exist for this message. |
referencedMessage | Message/nil | If available, the previous message that this current message references as seen in replies. |
sticker | Sticker | The first sticker that is sent in this message. |
stickers | ArrayIterable | An iterable array of all stickers that are sent in this message. |
tts | boolean | Whether this message is a text-to-speech message. |
type | number | The message type. Use the messageType enumeration for a human-readable representation. |
webhookId | string/nil | The ID of the webhook that generated this message, if applicable. |
Methods Inherited From Snowflake
Defines the behavior of the ==
operator. Allows containers to be directly compared according to their type and __hash
return values.
Returns: boolean
Returns Snowflake.id
Returns: string
Defines the behavior of the tostring
function. All containers follow the format ClassName: hash
.
Returns: string
Returns a unique Date object that represents when the object was created by Discord. Equivalent to Date.fromSnowflake(Snowflake.id)
This method only operates on data in memory.
Returns: Date
Parameter | Type |
---|---|
emoji | Emoji-Resolvable |
Adds a reaction to the message. Note that this does not return the new reaction object; wait for the reactionAdd
event instead.
This method always makes an HTTP request.
Returns: boolean
Removes all reactions from the message.
This method always makes an HTTP request.
Returns: boolean
Publish this announcement message to all following channels. Returns the current Message object, for compatibility reasons.
This method always makes an HTTP request.
Returns: Message
Permanently deletes the message. This cannot be undone!
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
flag | Message-Flag-Resolvable |
Indicates whether the message has a particular flag set.
This method only operates on data in memory.
Returns: boolean
Hides all embeds for this message.
This method always makes an HTTP request.
Returns: boolean
Pins the message in the channel.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type | Optional |
---|---|---|
emoji | Emoji-Resolvable | |
id | User-ID-Resolvable | ✔ |
Removes a reaction from the message. Note that this does not return the old reaction object; wait for the reactionRemove
event instead. If no user is indicated, then this will remove the current user's reaction.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
content | string/table |
Equivalent to Message.channel:send(content)
.
This method always makes an HTTP request.
Returns: Message
Parameter | Type |
---|---|
content | string |
Sets the message's content. The message must be authored by the current user (ie: you cannot change the content of messages sent by other users). The content must be from 1 to 2000 characters in length.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
embed | table |
Sets the message's embed. The message must be authored by the current user. (ie: you cannot change the embed of messages sent by other users).
This method always makes an HTTP request.
Returns: boolean
Shows all embeds for this message.
This method always makes an HTTP request.
Returns: boolean
Unpins the message in the channel.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
data | table |
Sets multiple properties of the message at the same time using a table similar to the one supported by TextChannel.send
, except only content
and embed(s)
are valid fields; mention(s)
, file(s)
, etc are not supported. The message must be authored by the current user. (ie: you cannot change the embed of messages sent by other users).
This method always makes an HTTP request.
Returns: boolean