Skip to content

Message

Implementation of the Discord Message class in Luau

https://discord.com/developers/docs/resources/message#message-object

Properties

id

Message.id  :: string

The ID of the message.

channelId

Message.channelId  :: string

The ID of the channel the message was sent in.

author

Message.author  :: Classes.User

The author of this message.

content

Message.content  :: string

The content of the message.

timestamp

Message.timestamp  :: DateTime

When this message was sent.

tts

Message.tts  :: boolean

Whether this was a TTS message.

mentionEveryone

Message.mentionEveryone  :: boolean

Whether this message mentions everyone.

mentionChannels

Message.mentionChannels  :: { Classes.ChannelMention }

Channels specifically mentioned in this message.

mentionRoles

Message.mentionRoles  :: { Classes.Role }

Roles specifically mentioned in this message.

mentionChannels

Message.mentionChannels  :: { Classes.ChannelMention }

Channels specifically mentioned in this message.

attachments

Message.attachments  :: { Classes.Attachment }

Any attachments to the message.

embeds

Message.embeds  :: { Classes.Embed }

Any embedded content in the message.

reactions

Message.reactions  :: { Classes.Reaction }

Reactions to the message.

nonce

Message.nonce  :: string

Used for validating a message was sent.

pinned

Message.pinned  :: boolean

Whether this message is pinned.

webhookId

Message.webhookId  :: string

If the message is generated by a webhook, this is the webhook’s ID.

activity

Message.activity  :: Classes.Activity

Activity information for Rich Presence messages.

application

Message.application  :: Classes.Application

Application information for Rich Presence messages.

applicationId

Message.applicationId  :: string

If the message is an Interaction or application-owned webhook, this is the ID of the application.

flags

Message.flags  :: Classes.MessageBitflag

Message flags combined as a bitfield.

messageReference

Message.messageReference  :: Classes.Reference

Reference data for crossposted messages and replies.

referencedMessage

Message.referencedMessage  :: Classes.Message

The message that was referenced in a reply.

interactionMetadata

Message.interactionMetadata  :: Classes.IneractionMetadata

Metadata for interaction messages.

interaction

Message.interaction  :: Classes.Interaction

Interaction information if the message is a response to an Interaction.

components


Components attached to the message.

stickerItems

Message.stickerItems  :: { Classes.StickerItem }

Stickers attached to the message.

position

Message.position  :: number

Position of the message in a thread.

roleSubscriptionData

Message.roleSubscriptionData  :: Classes.RoleSubscriptionData

Data for role subscription purchase or renewal notifications.

poll

Message.poll  :: Classes.Poll

Poll attached to the message.

call

Message.call  :: Classes.Call

Call information if this message started a call.

resolved

Message.resolved  :: table

Resolved objects from the interaction data.

Methods

The Message instance has no set methods!

Functions

startThreadAsync

Message . startThreadAsync (

     self: Message
     threadName: string
     autoArchiveDuration: number
     rateLimitPerUser: number?
)  -> ()

Creates a new thread from an existing message.

addReactionAsync

Message . addReactionAsync (

     self: Message
     emoji: builders.emojiJSON | string
)  -> ()

Add a reaction to a message. Requires READ_MESSAGE_HISTORY and ADD_REACTIONS permissions.

removeOwnReactionAsync

Message . removeOwnReactionAsync (

     self: Message
     emoji: builders.emojiJSON | string
)  -> ()

Remove the current user’s reaction from a message

deleteUserReactionAsync

Message . deleteUserReactionAsync (

     self: Message
     emoji: builders.emojiJSON | string
     userId: apiTypes.Snowflake
)  -> ()

Remove another user’s reaction from a message. Requires MANAGE_MESSAGES permission.

getReactionsAsync

Message . getReactionsAsync (

     self: Message
     emoji: builders.emojiJSON | string
     reactionType: apiTypes.ReactionType?
     afterUserId: apiTypes.Snowflake?
     limit: number?
)  -> ()

Get a list of users that reacted with a specific emoji

deleteAllReactionsAsync

Message . deleteAllReactionsAsync (

     self: Message
)  -> ()

Remove all reactions from a message. Requires MANAGE_MESSAGES permission.

deleteAllReactionsForEmojiAsync

Message . deleteAllReactionsForEmojiAsync (

     self: Message
     emoji: builders.emojiJSON | string
)  -> ()

Remove all reactions of a specific emoji from a message. Requires MANAGE_MESSAGES permission.

editAsync

Message . editAsync (

     self: Message
     message: builders.messageJSON
)  -> ()

Edit a message. The current user must be the author of the message.

deleteAsync

Message . deleteAsync (

     self: Message
     reason: string?
)  -> ()

Delete a message. If operating on a guild channel and trying to delete a message that was not sent by the current user, this endpoint requires the MANAGE_MESSAGES permission.

replyAsync

Message . replyAsync (

     self: Message
     message: builders.messageJSON
)  -> ()

Reply to a message by creating a new message that references this one.

pinAsync

Message . pinAsync (

     self: Message
)  -> ()

Pin this message to the channel. Requires MANAGE_MESSAGES permission.

unpinAsync

Message . unpinAsync (

     self: Message
)  -> ()

Unpin this message from the channel. Requires MANAGE_MESSAGES permission.

sync

Message . sync (

     self: Message
     messageData: apiTypes.MessageObject
)  -> ()

Synchronizes the message object with the data from the API.

new

Message . new (

     state: state.State
     messageData: apiTypes.MessageObject
)  -> ()

Creates a new Message instance with the specified message data.