Message

Message

A message belonging to a channel within a guild.

Constructor

new Message(client, data, options)

Description:
  • Creates the structure for a message.

Source:
See:
Parameters:
Name Type Description
client Client

The client instance.

data Object

Message data returned from Discord.

options Object

Additional options for this structure.

Properties
Name Type Attributes Description
channelId String

The id of the channel that the message belongs to.

guildId String

The id of the guild that the channel belongs to.

nocache Boolean <nullable>

Whether this message should be cached or not.

ignoreExisting Boolean <nullable>

Whether to ignore existing messages in the cache.

Members

(readonly) attachments :Array.<Attachment>

Description:
  • The message attachments.

Source:

The message attachments.

Type:

(readonly) author :User

Description:
  • The user who sent the message.

Source:

The user who sent the message.

Type:

(readonly) authorId :String

Description:
  • The id of the user who sent the message.

Source:

The id of the user who sent the message.

Type:
  • String

(readonly, nullable) channel :Channel

Description:
  • The channel that this message belongs to.

Source:

The channel that this message belongs to.

Type:

(readonly) channelId :String

Description:
  • The channel that this message belongs to.

Source:

The channel that this message belongs to.

Type:
  • String

(readonly, nullable) content :String

Description:
  • The message content.

Source:

The message content.

Type:
  • String

(readonly, nullable) editedTimestamp :Number

Description:
  • The timestamp for when this message was last edited.

Source:

The timestamp for when this message was last edited.

Type:
  • Number

(readonly) embeds :Array.<Embed>

Description:
  • The message embeds.

Source:

The message embeds.

Type:

(readonly) flags :Array.<String>

Description:
  • The flags of the message.

Source:
See:

The flags of the message.

Type:
  • Array.<String>

(readonly) flagsRaw :Number

Description:
  • The raw flags of the message.

Source:

The raw flags of the message.

Type:
  • Number

(readonly, nullable) guild :Guild

Description:
  • The guild that this message belongs to.

Source:

The guild that this message belongs to.

Type:

(readonly) guildId :String

Description:
  • The guild that this message belongs to.

Source:

The guild that this message belongs to.

Type:
  • String

(readonly) hashName :String

Description:
  • The hash name for the message.

Source:

The hash name for the message.

Type:
  • String

(readonly) id :String

Description:
  • The id of the message.

Source:

The id of the message.

Type:
  • String

(readonly, nullable) member :Member

Description:
  • The member who sent the message.

Source:

The member who sent the message.

Type:

(readonly) mentionEveryone :Boolean

Description:
  • Whether this message mentions everyone.

Source:

Whether this message mentions everyone.

Type:
  • Boolean

(readonly) mentionRoles :Boolean

Description:
  • Whether this message includes role mentions.

Source:

Whether this message includes role mentions.

Type:
  • Boolean

(readonly) mentions :Boolean

Description:
  • Whether this message includes user mentions.

Source:

Whether this message includes user mentions.

Type:
  • Boolean

(readonly, nullable) messageSnapshots :Object

Description:
  • The snapshot data about the message.

Source:

The snapshot data about the message.

Type:
  • Object

(readonly) mirrored :Boolean

Description:
  • Whether another message has replaced this original message.

Source:

Whether another message has replaced this original message.

Type:
  • Boolean

(readonly) pinned :Boolean

Description:
  • Whether this message has been pinned.

Source:

Whether this message has been pinned.

Type:
  • Boolean

(readonly, nullable) poll :Poll

Description:
  • The message poll.

Source:

The message poll.

Type:

(readonly) reactions :MessageReactionManager

Description:
  • The message reactions.

Source:

The message reactions.

Type:

(readonly) reference :Object

Description:
  • The message that this message references.

Source:

The message that this message references.

Type:
  • Object

(readonly) stickerItems :Array.<Sticker>

Description:
  • Stickers sent with this message.

Source:

Stickers sent with this message.

Type:

(readonly) timestamp :Number

Description:
  • The UNIX (seconds) timestamp for when this message was created.

Source:

The UNIX (seconds) timestamp for when this message was created.

Type:
  • Number

(readonly) type :Number

Description:
  • The type of message.

Source:

The type of message.

Type:
  • Number

(readonly) url :String

Description:
  • The URL of the message.

Source:

The URL of the message.

Type:
  • String

(readonly, nullable) webhookId :String

Description:
  • The id of the webhook this message is from.

Source:

The id of the webhook this message is from.

Type:
  • String

Methods

(static) decrypt(client, data, guildId, channelId, messageId) → {Message}

Description:
  • Decrypts a message.

Source:
Parameters:
Name Type Description
client Client

The client instance.

data String

The encrypted message data.

guildId String

The id of the guild that the message belongs to.

channelId String

The id of the channel that the message belongs to.

messageId String

The id of the message.

Throws:
TypeError
Returns:
Type
Message

(async, static) delete(client, channelId, messageId, optionsnullable) → {Promise.<void>}

Description:
  • Deletes one message.

Source:
Parameters:
Name Type Attributes Description
client Client

The client instance.

channelId String

The id of the channel that the message belongs to.

messageId String

The id of the message to delete.

options Object <nullable>
Properties
Name Type Attributes Description
reason String <nullable>

The reason for deleting the message.

Throws:
TypeError
Returns:
Type
Promise.<void>

(async, static) edit(client, channelId, messageId, guildId, optionsnullable) → {Promise.<Message>}

Description:
  • Edits a message.

Source:
Parameters:
Name Type Attributes Description
client Client

The client instance.

channelId String

The id of the channel the message belongs to.

messageId String

The id of the message.

guildId String

The id of the guild the message belongs to.

options Object <nullable>

The message options.

Properties
Name Type Attributes Description
content String <nullable>

The message content.

embeds Array.<Embed> <nullable>

Array of embeds to send with the message.

components MessageComponents <nullable>

Message components to send with the message.

files Array.<FileUpload> <nullable>

Array of file objects for files to send with the message.

attachments Array.<Attachment> <nullable>

Array of attachment objects for existing attachments sent with the message.

Returns:
Type
Promise.<Message>

(static) getHashName(guildId, channelId, messageId) → {String}

Description:
  • Returns the hash name for the message.

Source:
Parameters:
Name Type Description
guildId String

The id of the guild that the message belongs to.

channelId String

The id of the channel that the message belongs to.

messageId String

The id of the message.

Throws:
TypeError
Returns:
Type
String

(static) getUrl(guildId, channelId, messageId) → {String}

Description:
  • The URL of the message.

Source:
Parameters:
Name Type Description
guildId String

The id of the guild that the message belongs to.

channelId String

The id of the channel that the message belongs to.

messageId String

The id of the message.

Returns:
Type
String

(async, static) send(client, channelId, guildId, optionsnullable) → {Promise.<Message>}

Description:
  • Posts a message to the specified channel.

Source:
Parameters:
Name Type Attributes Description
client Client

The client instance.

channelId String

The id of the channel to send the message to.

guildId String

The id of the guild which the channel belongs to.

options Object <nullable>

Content, embeds, components and files to attach to the message.

Properties
Name Type Attributes Description
content String <nullable>

The message content.

embeds Array.<Embed>

Array of embeds to send with the message.

components MessageComponents <nullable>

Message components to send with the message.

files Array.<FileUpload> <nullable>

Array of file objects for files to send with the message.

suppressMentions Boolean <nullable>

Whether to suppress mentions in the message.

Throws:
TypeError
Returns:
Type
Promise.<Message>

(static) sendValidation(options) → {void}

Description:
  • Validates the message content, embeds, components and files.

Source:
Parameters:
Name Type Description
options Object

The message options.

Properties
Name Type Description
content String

The message content.

embeds Array.<Embed>

Array of embeds to send with the message.

components MessageComponents

Message components to send with the message.

files Array.<FileUpload>

Array of file objects for files to send with the message.

attachments Array.<Attachment>

Array of attachment objects for existing attachments sent with the message.

flags Number

The message flags.

reference Object

The message reference.

Properties
Name Type Description
message_id String

The id of the message to reference.

channel_id String

The id of the channel to reference.

guild_id String

The id of the guild to reference.

Throws:
Error | TypeError | RangeError
Returns:
Type
void

(static) shouldCache(gluonCacheOptions, guildCacheOptions, channelCacheOptions) → {Boolean}

Description:
  • Determines whether the message should be cached.

Source:
Parameters:
Name Type Description
gluonCacheOptions GluonCacheOptions

The cache options for the client.

guildCacheOptions GuildCacheOptions

The cache options for the guild.

channelCacheOptions ChannelCacheOptions

The cache options for the channel.

Returns:
Type
Boolean

(async) delete(optionsnullable) → {Promise.<void>}

Description:
  • Deletes the message.

Source:
Parameters:
Name Type Attributes Description
options Object <nullable>

The options for deleting the message.

Properties
Name Type Attributes Description
reason String <nullable>

The reason for deleting the message

Returns:
Type
Promise.<void>

(async) edit(optionsnullable) → {Promise.<Message>}

Description:
  • Edits the message, assuming it is sent by the client user.

Source:
See:
Parameters:
Name Type Attributes Description
options Object <nullable>

Content, embeds and components to attach to the message.

Properties
Name Type Attributes Description
content String <nullable>

The message content.

embed Embed <nullable>

Embed to send with the message.

components MessageComponents <nullable>

Message components to send with the message.

attachments Array.<Attachment> <nullable>

Array of attachment objects for files to send with the message.

flags Number <nullable>

The message flags.

reference Object <nullable>

The message reference.

Properties
Name Type Attributes Description
message_id String <nullable>

The id of the message to reference.

channel_id String <nullable>

The id of the channel to reference.

guild_id String <nullable>

The id of the guild to reference.

files Array.<FileUpload> <nullable>

Array of file objects for files to send with the message.

Throws:
Error | TypeError
Returns:
Type
Promise.<Message>

encrypt() → {String}

Description:
  • Encrypts the message.

Source:
Returns:
Type
String

(async) reply(optionsnullable) → {Promise.<Message>}

Description:
  • Replies to the message.

Source:
See:
Parameters:
Name Type Attributes Description
options Object <nullable>

Embeds, components and files to attach to the message.

Properties
Name Type Attributes Description
content String <nullable>

The message content.

embed Embed <nullable>

Embed to send with the message.

components MessageComponents <nullable>

Message components to send with the message.

files Array.<FileUpload> <nullable>

Array of file objects for files to send with the message.

Throws:
Error | TypeError
Returns:
Type
Promise.<Message>

toJSON(format) → {Object}

Description:
  • Returns the JSON representation of this structure.

Source:
Parameters:
Name Type Description
format Number

The format to return the data in.

Returns:
Type
Object

toString()

Source: