Class: MessageManager

MessageManager

Manages API methods for Messages and holds their cache.

Constructor

new MessageManager()

Source:

Extends

Members

cache :Collection.<Snowflake, Message>

The cache of Messages
Type:
Overrides:
Source:

cacheType :Collection

The type of Collection of the Manager
Type:
  • Collection
Overrides:
Source:

channel :TextBasedChannel

The channel that the messages belong to
Type:
Source:

(readonly) client :Client

The client that instantiated this Manager
Type:
Overrides:
Source:

(private, readonly) holds :function

The data structure belonging to this manager
Type:
  • function
Overrides:
Source:

Methods

delete(message, reasonopt) → {Promise.<void>}

Deletes a message, even if it's not cached.
Parameters:
Name Type Attributes Description
message MessageResolvable The message to delete
reason string <optional>
Reason for deleting this message, if it does not belong to the client user
Source:
Returns:
Type
Promise.<void>

fetch(messageopt, cacheopt, forceopt) → {Promise.<Message>|Promise.<Collection.<Snowflake, Message>>}

Gets a message, or messages, from this channel. The returned Collection does not contain reaction users of the messages if they were not cached. Those need to be fetched separately in such a case.
Parameters:
Name Type Attributes Default Description
message Snowflake | ChannelLogsQueryOptions <optional>
The ID of the message to fetch, or query parameters.
cache boolean <optional>
true Whether to cache the message(s)
force boolean <optional>
false Whether to skip the cache check and request the API
Source:
Returns:
Type
Promise.<Message> | Promise.<Collection.<Snowflake, Message>>
Examples
// Get message
channel.messages.fetch('99539446449315840')
  .then(message => console.log(message.content))
  .catch(console.error);
// Get messages
channel.messages.fetch({ limit: 10 })
  .then(messages => console.log(`Received ${messages.size} messages`))
  .catch(console.error);
// Get messages and filter by user ID
channel.messages.fetch()
  .then(messages => console.log(`${messages.filter(m => m.author.id === '84484653687267328').size} messages`))
  .catch(console.error);

fetchPinned(cacheopt) → {Promise.<Collection.<Snowflake, Message>>}

Fetches the pinned messages of this channel and returns a collection of them. The returned Collection does not contain any reaction data of the messages. Those need to be fetched separately.
Parameters:
Name Type Attributes Default Description
cache boolean <optional>
true Whether to cache the message(s)
Source:
Returns:
Type
Promise.<Collection.<Snowflake, Message>>
Example
// Get pinned messages
channel.messages.fetchPinned()
  .then(messages => console.log(`Received ${messages.size} messages`))
  .catch(console.error);

resolve(message) → {Message}

Resolves a MessageResolvable to a Message object.
Parameters:
Name Type Description
message MessageResolvable The message resolvable to resolve
Overrides:
Source:
Returns:
Type
Message

resolveID(message) → {Snowflake}

Resolves a MessageResolvable to a Message ID string.
Parameters:
Name Type Description
message MessageResolvable The message resolvable to resolve
Overrides:
Source:
Returns:
Type
Snowflake