MessageManager
MessageManager ⇐ Base
Represents a message manager for a specific guild and channel.
Kind: global class
Extends: Base
- MessageManager ⇐
Base
- new MessageManager(guildId, channelId, client)
- instance
- .guild ⇒
- .cache ⇒
- ._add(messages, [guildId], [channelId], [options])
- .send([channel], [options]) ⇒
Promise.<Message>
- .bulkDelete([channel], [message], [reason]) ⇒
Promise.<Array>
- .delete(message, reason) ⇒
Promise.<Message>
- .edit(message, options) ⇒
Promise.<Message>
- .fetch(message, [options]) ⇒
Promise.<(Message|Map.<string, Message>)>
- ._fetchId(message, [cache], [force]) ⇒
Promise.<object>
- .crosspost(channel, message) ⇒
Promise.<Message>
- .react(message, emoji) ⇒
Promise.<void>
- .pins() ⇒
Promise.<Cache>
- .unpin(message, reason) ⇒
Promise.<void>
- .pin(message, reason) ⇒
Promise.<void>
- static
- .transformOptions(o) ⇒
Object
|null
- .transformOptions(o) ⇒
new MessageManager(guildId, channelId, client)
Constructs a new instance of the class.
Param | Type | Description |
---|---|---|
guildId | string | The ID of the guild. |
channelId | string | The ID of the channel. |
client | Client | The 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
Param | Type | Default | Description |
---|---|---|---|
messages | string | Message | The 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] | boolean | true | Whether to cache the message. |
[options.force] | boolean | false | Whether 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.
Param | Type | Default | Description |
---|---|---|---|
[channel] | string | Channel | ”this.channelId” | The channel to send the message to. Can be either a channel ID or a Channel object. |
[options] | object | Additional 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
Param | Type | Default | Description |
---|---|---|---|
[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] | string | The 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.
Param | Type | Description |
---|---|---|
message | string | Message | The message to delete. Can be either the message ID or the message object itself. |
reason | string | The 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.
Param | Type | Description |
---|---|---|
message | string | Message | The message or message ID to edit. |
options | Object | The 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.
Param | Type | Default | Description |
---|---|---|---|
message | string | object | The ID of the message to fetch or an object containing options for fetching messages. | |
[options] | object | Additional options for fetching messages. | |
[options.cache] | boolean | true | Whether to cache the fetched messages. |
[options.force] | boolean | false | Whether 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.
Param | Type | Default | Description |
---|---|---|---|
message | string | object | The ID of the message or the message object itself. | |
[cache] | boolean | true | Whether to cache the fetched message. |
[force] | boolean | false | Whether 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.
Param | Type | Description |
---|---|---|
channel | string | Channel | The channel to crosspost the message to. |
message | string | Message | The 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.
Param | Type | Description |
---|---|---|
message | string | Message | The message to react to. Can be either a message ID or a Message object. |
emoji | string | The 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.
Param | Type | Description |
---|---|---|
message | string | Message | The message or message ID to unpin. |
reason | string | The 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.
Param | Type | Description |
---|---|---|
message | string | Message | The message or message ID to pin. |
reason | string | The 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.
Param | Type | Description |
---|---|---|
o | Object | The options object to transform. |