Message
Message ⇐ Base
Section titled “Message ⇐ Base”Represents a message in a chat channel.
Kind: global class
Extends: Base
- Message ⇐
Base- new Message(data, guildId, channelId, client)
- .channel ⇒
- .guild ⇒
- .system ⇒
boolean|null - .author ⇒
- .edit(options) ⇒
Promise - .delete(reason) ⇒
Promise - .fetch([options]) ⇒
Promise - .crosspost() ⇒
Promise.<void> - .react(emoji) ⇒
Promise.<void> - .removeEmbeds() ⇒
Promise.<void> - .removeAttachments() ⇒
Promise.<void> - .removeAttachment(attachment) ⇒
Promise.<void> - .reply(options) ⇒
Promise.<Message> - .fetchReference() ⇒
Promise.<Message> - .pin(reason) ⇒
Promise - .unpin(reason) ⇒
Promise - .inGuild() ⇒
boolean - .equals(message) ⇒
boolean|null - .createThread([options]) ⇒
Promise.<Thread> - .addAttachments(attachments) ⇒
Promise
new Message(data, guildId, channelId, client)
Section titled “new Message(data, guildId, channelId, client)”Constructs a new instance of the Message class.
| Param | Type | Description |
|---|---|---|
| data | Object | The data object containing information about the message. |
| guildId | string | The ID of the guild the message belongs to. |
| channelId | string | The ID of the channel the message belongs to. |
| client | Client | The client instance. |
message.channel ⇒
Section titled “message.channel ⇒”Retrieves the channel associated with this object.
Kind: instance property of Message
Returns: The channel object if found, otherwise null.
message.guild ⇒
Section titled “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
Section titled “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 ⇒
Section titled “message.author ⇒”Get the author of this object.
Kind: instance property of Message
Returns: The author of this object.
message.edit(options) ⇒ Promise
Section titled “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.
| Param | Type | Description |
|---|---|---|
| options | Object | The options to edit the message with. |
message.delete(reason) ⇒ Promise
Section titled “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.
| Param | Type | Description |
|---|---|---|
| reason | string | The reason for deleting the message. |
message.fetch([options]) ⇒ Promise
Section titled “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.
| Param | Type | Description |
|---|---|---|
| [options] | Object | The options to customize the fetch request. |
message.crosspost() ⇒ Promise.<void>
Section titled “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>
Section titled “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.
| Param | Type | Description |
|---|---|---|
| emoji | string | The emoji to react with. |
message.removeEmbeds() ⇒ Promise.<void>
Section titled “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>
Section titled “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:
RangeErrorIf there are no attachments in the message.
message.removeAttachment(attachment) ⇒ Promise.<void>
Section titled “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.
| Param | Type | Description |
|---|---|---|
| attachment | string | Attachment | The attachment or attachment ID to remove. |
message.reply(options) ⇒ Promise.<Message>
Section titled “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.
| Param | Type | Description |
|---|---|---|
| options | Object | Additional options for the reply message. |
message.fetchReference() ⇒ Promise.<Message>
Section titled “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
Section titled “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.
| Param | Type | Description |
|---|---|---|
| reason | string | The reason for pinning the message. |
message.unpin(reason) ⇒ Promise
Section titled “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.
| Param | Type | Description |
|---|---|---|
| reason | string | The reason for unpinning the message. |
message.inGuild() ⇒ boolean
Section titled “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
Section titled “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.
| Param | Type | Description |
|---|---|---|
| message | Object | The object to compare with this Message object. |
message.createThread([options]) ⇒ Promise.<Thread>
Section titled “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.
| Param | Type | Description |
|---|---|---|
| [options] | Object | The options for creating the thread. |
| [options.reason] | string | The reason for creating the thread. |
| [options.name] | string | The name of the thread. |
| [options.autoArchiveDuration] | number | The duration in minutes to automatically archive the thread. |
| [options.ratelimit] | number | The rate limit per user in the thread. |
message.addAttachments(attachments) ⇒ Promise
Section titled “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.
| Param | Type | Description |
|---|---|---|
| attachments | Array | An array of attachment objects to add to the message. |