Skip to content

Message

Message ⇐ Base

Represents a message in a chat channel.

Kind: global class
Extends: Base

new Message(data, guildId, channelId, client)

Constructs a new instance of the Message class.

ParamTypeDescription
dataObjectThe data object containing information about the message.
guildIdstringThe ID of the guild the message belongs to.
channelIdstringThe ID of the channel the message belongs to.
clientClientThe client instance.

message.channel ⇒

Retrieves the channel associated with this object.

Kind: instance property of Message
Returns: The channel object if found, otherwise null.

message.guild ⇒

Retrieves the guild associated with this guildId from the client’s guild cache.

Kind: instance property of Message
Returns: The guild object if found, otherwise null.

message.system ⇒ boolean | null

Get the system value based on the type of the object.

Kind: instance property of Message
Returns: boolean | null - - The system value. Returns null if the type is not set.

message.author ⇒

Get the author of this object.

Kind: instance property of Message
Returns: The author of this object.

message.edit(options) ⇒ Promise

Edits the message with the given options.

Kind: instance method of Message
Returns: Promise - A promise that resolves when the message has been edited.

ParamTypeDescription
optionsObjectThe options to edit the message with.

message.delete(reason) ⇒ Promise

Deletes the message from the channel.

Kind: instance method of Message
Returns: Promise - A promise that resolves when the message is successfully deleted.

ParamTypeDescription
reasonstringThe reason for deleting the message.

message.fetch([options]) ⇒ Promise

Fetches messages from the channel using the given options.

Kind: instance method of Message
Returns: Promise - - A promise that resolves with the fetched messages.

ParamTypeDescription
[options]ObjectThe options to customize the fetch request.

message.crosspost() ⇒ Promise.<void>

Crossposts a message to another channel.

Kind: instance method of Message
Returns: Promise.<void> - - A promise that resolves when the crossposting is complete.

message.react(emoji) ⇒ Promise.<void>

Reacts to a message with the specified emoji.

Kind: instance method of Message
Returns: Promise.<void> - - A promise that resolves when the reaction is added.

ParamTypeDescription
emojistringThe emoji to react with.

message.removeEmbeds() ⇒ Promise.<void>

Removes embeds from a message.

Kind: instance method of Message
Returns: Promise.<void> - - A promise that resolves when the embeds are successfully removed.

message.removeAttachments() ⇒ Promise.<void>

Removes all attachments from the message.

Kind: instance method of Message
Returns: Promise.<void> - A promise that resolves when the attachments are successfully removed.
Throws:

  • RangeError If there are no attachments in the message.

message.removeAttachment(attachment) ⇒ Promise.<void>

Removes the specified attachment from the message. If no attachment is provided, all attachments will be removed.

Kind: instance method of Message
Returns: Promise.<void> - - A promise that resolves once the attachment is removed.
Throws:

  • RangeError - If the message does not have the specified attachment.
ParamTypeDescription
attachmentstring | AttachmentThe attachment or attachment ID to remove.

message.reply(options) ⇒ Promise.<Message>

Sends a reply message to the channel where the original message was received.

Kind: instance method of Message
Returns: Promise.<Message> - - A promise that resolves to the sent message.

ParamTypeDescription
optionsObjectAdditional options for the reply message.

message.fetchReference() ⇒ Promise.<Message>

Fetches the reference message from the channel.

Kind: instance method of Message
Returns: Promise.<Message> - A promise that resolves to the reference message.

message.pin(reason) ⇒ Promise

Pins the current message to the channel.

Kind: instance method of Message
Returns: Promise - - A promise that resolves when the message is successfully pinned.

ParamTypeDescription
reasonstringThe reason for pinning the message.

message.unpin(reason) ⇒ Promise

Unpins the current message from the channel.

Kind: instance method of Message
Returns: Promise - - A promise that resolves when the message is successfully unpinned.

ParamTypeDescription
reasonstringThe reason for unpinning the message.

message.inGuild() ⇒ boolean

Checks if the current context is within a guild.

Kind: instance method of Message
Returns: boolean - - True if the context is within a guild, false otherwise.

message.equals(message) ⇒ boolean | null

Checks if the given object is equal to this Message object.

Kind: instance method of Message
Returns: boolean | null - - Returns true if the objects are equal, false if they are not equal, and null if the given object is not an instance of Message.

ParamTypeDescription
messageObjectThe object to compare with this Message object.

message.createThread([options]) ⇒ Promise.<Thread>

Creates a new thread in a channel.

Kind: instance method of Message
Returns: Promise.<Thread> - A promise that resolves with the created thread.

ParamTypeDescription
[options]ObjectThe options for creating the thread.
[options.reason]stringThe reason for creating the thread.
[options.name]stringThe name of the thread.
[options.autoArchiveDuration]numberThe duration in minutes to automatically archive the thread.
[options.ratelimit]numberThe rate limit per user in the thread.

message.addAttachments(attachments) ⇒ Promise

Adds attachments to the message.

Kind: instance method of Message
Returns: Promise - - A promise that resolves when the attachments have been added.
Throws:

  • RangeError - If the message has no attachments or if one of the specified attachments already exists.
ParamTypeDescription
attachmentsArrayAn array of attachment objects to add to the message.