Skip to main content
Version: 0.6.4

Class: MessageManager

Extends​

Constructors​

Constructor​

new MessageManager(client, channel, limit?): MessageManager

Parameters​

ParameterTypeDefault value
clientClientundefined
channelBaseChannelundefined
limitnumberInfinity

Returns​

MessageManager

Overrides​

BaseManager<string, Message>.constructor

Properties​

cache​

cache: Collection<string, Message>

Inherited from​

BaseManager.cache


channel​

channel: BaseChannel


client​

client: Client

Inherited from​

BaseManager.client

Methods​

[custom]()​

[custom](): Collection<string, Message>

Returns​

Collection<string, Message>


clearReactions()​

clearReactions(message): Promise<void>

Remove all reactions from a message Requires ManageMessages permission.

Parameters​

ParameterTypeDescription
messageMessageResolvableThe MessageResolvable to clear reactions from.

Returns​

Promise<void>

Throws​

If the API request fails.

Example​

await channel.messages.clearReactions(messageId);

construct()​

protected construct(data): Message

Tell BaseManager how to build a Message

Parameters​

ParameterType
data{ }

Returns​

Message

Overrides​

BaseManager.construct


delete()​

delete(message): Promise<void>

Deletes a message from the channel.

Parameters​

ParameterTypeDescription
messageMessageResolvableThe MessageResolvable to delete.

Returns​

Promise<void>


edit()​

edit(message, contentOrOptions): Promise<Message>

Edits an existing message.

Parameters​

ParameterTypeDescription
messageMessageResolvableThe MessageResolvable (object or ID) to edit.
contentOrOptionsstring | MessageOptionsThe new content or options.

Returns​

Promise<Message>

A promise that resolves to the updated Message.


extractId()​

protected extractId(data): string

Tell BaseManager how to find the ID for Messages

Parameters​

ParameterType
data{ }

Returns​

string

Overrides​

BaseManager.extractId


fetch()​

fetch(id): Promise<Message>

Parameters​

ParameterType
idstring

Returns​

Promise<Message>


fetchMany()​

fetchMany(options?): Promise<Collection<string, Message>>

Fetches multiple messages from the channel using specific filter parameters.

Parameters​

ParameterTypeDescription
optionsMessageFetchOptionsThe query parameters to filter the fetched messages.

Returns​

Promise<Collection<string, Message>>

A promise that resolves to a Collection of fetched Messages.

Throws​

If the API request fails.

Example​

// Fetch the last 50 messages in the channel
const messages = await channel.messages.fetchMany({ limit: 50, sort: "Latest" });

// Fetch 20 messages before a specific message ID
const history = await channel.messages.fetchMany({ limit: 20, before: "01H..." });

pin()​

pin(message): Promise<void>

Pins a message in the channel.

Parameters​

ParameterTypeDescription
messageMessageResolvableThe MessageResolvable to pin.

Returns​

Promise<void>


react()​

react(message, reaction): Promise<void>

React to a message

Parameters​

ParameterTypeDescription
messageMessageResolvableThe MessageResolvable to react to.
reactionstringThe emoji to react with. Can be a Unicode emoji or a custom emoji ID.

Returns​

Promise<void>

Throws​

If the API request fails.

Example​

await channel.messages.react(messageId, "👍");
await channel.messages.react(messageId, "customEmojiId");

removeReaction()​

removeReaction(message, reaction, userId?, removeAll?): Promise<void>

Remove a reaction(s) from a message Requires ManageMessages if changing others' reactions.

Parameters​

ParameterTypeDescription
messageMessageResolvableThe MessageResolvable to remove the reaction from.
reactionstringThe emoji to remove. Can be a unicode emoji or a custom emoji ID.
userId?UserResolvableThe ID of the user whose reaction to remove. If not provided, removes the current user's reaction.
removeAll?booleanRemove all reactions of this type.

Returns​

Promise<void>

Throws​

If both userId and removeAll are provided, or if the API request fails.

Example​

// Remove the current user's reaction
await channel.messages.removeReaction(messageId, "👍");
// Remove a specific user's reaction
await channel.messages.removeReaction(messageId, "👍", userId);
// Remove all reactions of this type
await channel.messages.removeReaction(messageId, "👍", undefined, true);

resolveId()​

resolveId(message): string

Parameters​

ParameterType
messageMessageResolvable

Returns​

string


send()​

send(contentOrOptions): Promise<Message>

Sends a new message to this channel.

Parameters​

ParameterTypeDescription
contentOrOptionsstring | MessageOptionsThe string content or message options payload.

Returns​

Promise<Message>

A promise that resolves to the sent Message.


unpin()​

unpin(message): Promise<void>

Unpins a message in the channel.

Parameters​

ParameterTypeDescription
messageMessageResolvableThe MessageResolvable to unpin.

Returns​

Promise<void>