Skip to content

MessageManager

MessageManager ⇐ Base

Represents a message manager for a specific guild and channel.

Kind: global class
Extends: Base

new MessageManager(guildId, channelId, client)

Constructs a new instance of the class.

ParamTypeDescription
guildIdstringThe ID of the guild.
channelIdstringThe ID of the channel.
clientClientThe client instance.

messageManager.guild ⇒

Retrieves the guild associated with this guildId.

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

messageManager.cache ⇒

Getter method for the cache property.

Kind: instance property of MessageManager
Returns: The Collection object representing the cache.

messageManager._add(messages, [guildId], [channelId], [options])

Adds a message to the cache and returns the message object.

Kind: instance method of MessageManager

ParamTypeDefaultDescription
messagesstring | MessageThe message or message ID to add to the cache.
[guildId]string”this.guildId”The ID of the guild the message belongs to.
[channelId]string”this.channelId”The ID of the channel the message belongs to.
[options]object{cache: true, force: false}Additional options for adding the message.
[options.cache]booleantrueWhether to cache the message.
[options.force]booleanfalseWhether to force adding the message to the cache even if it

messageManager.send([channel], [options]) ⇒ Promise.<Message>

Sends a message to a specified channel.

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

ParamTypeDefaultDescription
[channel]string | Channel”this.channelId”The channel to send the message to. Can be either a channel ID or a Channel object.
[options]objectAdditional options for the message.

messageManager.bulkDelete([channel], [message], [reason]) ⇒ Promise.<Array>

Bulk deletes messages in a channel.

Kind: instance method of MessageManager
Returns: Promise.<Array> - - A promise that resolves to an array of deleted message IDs and their corresponding Message objects.
Throws:

  • RangeError
ParamTypeDefaultDescription
[channel]string | Channel”this.channelId”The channel ID or Channel object where the messages should be deleted.
[message]Array.<Message> | Map.<string, Message> | number[]The messages to be deleted. Can be an array of Message objects, a Map of Message objects, or a number representing the number of messages to fetch and delete.
[reason]stringThe reason for deleting the messages.

messageManager.delete(message, reason) ⇒ Promise.<Message>

Deletes a message from the channel.

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

ParamTypeDescription
messagestring | MessageThe message to delete. Can be either the message ID or the message object itself.
reasonstringThe reason for deleting the message.

messageManager.edit(message, options) ⇒ Promise.<Message>

Edits a message with the given options.

Kind: instance method of MessageManager
Returns: Promise.<Message> - A promise that resolves with the edited message.

ParamTypeDescription
messagestring | MessageThe message or message ID to edit.
optionsObjectThe options to update the message with.

messageManager.fetch(message, [options]) ⇒ Promise.<(Message|Map.<string, Message>)>

Fetches a message or a list of messages from the server.

Kind: instance method of MessageManager
Returns: Promise.<(Message|Map.<string, Message>)> - - A single message object if a message ID is provided, or a map of message IDs to message objects if options are provided.

ParamTypeDefaultDescription
messagestring | objectThe ID of the message to fetch or an object containing options for fetching messages.
[options]objectAdditional options for fetching messages.
[options.cache]booleantrueWhether to cache the fetched messages.
[options.force]booleanfalseWhether to force fetch the messages even if they are already cached.

messageManager._fetchId(message, [cache], [force]) ⇒ Promise.<object>

Fetches a message by its ID from the channel.

Kind: instance method of MessageManager
Returns: Promise.<object> - - A promise that resolves to the fetched message object.

ParamTypeDefaultDescription
messagestring | objectThe ID of the message or the message object itself.
[cache]booleantrueWhether to cache the fetched message.
[force]booleanfalseWhether to force fetch the message even if it is already cached.

messageManager.crosspost(channel, message) ⇒ Promise.<Message>

Crossposts a message to a specified channel.

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

ParamTypeDescription
channelstring | ChannelThe channel to crosspost the message to.
messagestring | MessageThe message to crosspost.

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

Reacts to a message with the specified emoji.

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

ParamTypeDescription
messagestring | MessageThe message to react to. Can be either a message ID or a Message object.
emojistringThe emoji to react with.

messageManager.pins() ⇒ Promise.<Cache>

Retrieves the pinned messages in the current channel.

Kind: instance method of MessageManager
Returns: Promise.<Cache> - A Promise that resolves to a Cache object containing the pinned messages.

messageManager.unpin(message, reason) ⇒ Promise.<void>

Unpins a message from the channel.

Kind: instance method of MessageManager
Returns: Promise.<void> - - A promise that resolves when the message is successfully unpinned.

ParamTypeDescription
messagestring | MessageThe message or message ID to unpin.
reasonstringThe reason for unpinning the message.

messageManager.pin(message, reason) ⇒ Promise.<void>

Pins a message in the channel.

Kind: instance method of MessageManager
Returns: Promise.<void> - - A promise that resolves when the message is pinned.

ParamTypeDescription
messagestring | MessageThe message or message ID to pin.
reasonstringThe reason for pinning the message.

MessageManager.transformOptions(o) ⇒ Object | null

Transforms the given options object into a new object with specific properties.

Kind: static method of MessageManager
Returns: Object | null - - The transformed object or null if the input is null.

ParamTypeDescription
oObjectThe options object to transform.