Message - truemedian/Discordia GitHub Wiki

Inherits Snowflake

Represents a text message sent in a Discord text channel. Messages can contain simple content strings, rich embeds, attachments, or reactions.

Methods

setContent
setEmbed
pin
unpin
addReaction
removeReaction
clearReactions
delete
reply

Properties

reactions
mentionedUsers
mentionedRoles
mentionedEmojis
mentionedChannels
cleanContent
mentionsEveryone
pinned
tts
nonce
editedTimestamp
oldContent
content
author
channel
type
embed
attachment
embeds
attachments
guild
member

Inherited from Container
client
parent

Inherited from Snowflake
id
createdAt
timestamp

Methods

:setContent( content )

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.

Name Type
content string

Returns: boolean

:setEmbed( embed )

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).

Name Type
embed table

Returns: boolean

:pin( )

Pins the message in the channel.

Returns: boolean

:unpin( )

Unpins the message in the channel.

Returns: boolean

:addReaction( emoji )

Adds a reaction to the message. Note that this does not return the new reaction object; wait for the reactionAdd event instead.

Name Type
emoji Emoji Resolvable

Returns: boolean

:removeReaction( emoji, [ id ] )

Removes a reaction from the message. Note that this does not return the old reaction object; wait for the reactionAdd event instead. If no user is indicated, then this will remove the current user's reaction.

Name Type Optional
emoji Emoji Resolvable
id User ID Resolvable x

Returns: boolean

:clearReactions( )

Removes all reactions from the message.

Returns: boolean

:delete( )

Permanently deletes the message. This cannot be undone!

Returns: boolean

:reply( content )

Equivalent to Message.channel:send(content).

Name Type
content string

Returns: Message

Properties

.reactions

An iterable cache of all reactions that exist for this message.

Type: Cache

.mentionedUsers

An iterable array of all users that are mentioned in this message. Object order is not guaranteed.

Type: ArrayIterable

.mentionedRoles

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. Object order is not guaranteed.

Type: ArrayIterable

.mentionedEmojis

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. Object order is not guaranteed.

Type: ArrayIterable

.mentionedChannels

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. Object order is not guaranteed.

Type: ArrayIterable

.cleanContent

The message content with all recognized mentions replaced by names and with @everyone and @here mentions escaped by a zero-width space (ZWSP).

Type: string

.mentionsEveryone

Whether this message mentions @everyone or @here.

Type: boolean

.pinned

Whether this message belongs to its channel's pinned messages.

Type: boolean

.tts

Whether this message is a text-to-speech message.

Type: boolean

.nonce

Used by the official Discord client to detect the success of a sent message.

Type: string|number|boolean|nil

.editedTimestamp

The date and time at which the message was most recently edited, represented as an ISO 8601 string plus microseconds when available.

Type: string|nil

.oldContent

Yields a table containing keys as timestamps and value as content of the message at that time.

Type: string|table

.content

The raw message content. This should be between 0 and 2000 characters in length.

Type: string

.author

The object of the user that created the message.

Type: User

.channel

The channel in which this message was sent.

Type: TextChannel

.type

The message type. Use the messageType enumeration for a human-readable representation.

Type: number

.embed

A raw data table that represents the first rich embed that exists in this message. See the Discord documentation for more information.

Type: table|nil

.attachment

A raw data table that represents the first file attachment that exists in this message. See the Discord documentation for more information.

Type: table|nil

.embeds

A raw data table that contains all embeds that exist for this message. If there are none, this table will not be present.

Type: table

.attachments

A raw data table that contains all attachments that exist for this message. If there are none, this table will not be present.

Type: table

.guild

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.

Type: Guild|nil

.member

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).

Type: Member|nil

Inherited from Container

.client

A shortcut to the client object to which this container is visible.

Type: Client

.parent

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.

Type: Container|Client

Inherited from Snowflake

.id

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.

Type: string

.createdAt

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.

Type: number

.timestamp

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().

Type: string

⚠️ **GitHub.com Fallback** ⚠️