export abstract class MessageManager<InGuild extends boolean = boolean> extends CachedManager<Snowflake, Message<InGuild>, MessageResolvable>
Manages API methods for Messages and holds their cache.
Constructors
channel: TextBasedChanneliterable?: Iterable<RawMessageData>)
constructor(Constructs a new instance of the MessageManager
class
readonlyCollection<Key, Holds> cache :
The cache of items for this manager.
Inherited from: DataManager
TextBasedChannel channel :
The channel that the messages belong to
readonlyConstructable<Holds> holds :
The data structure belonging to this manager.
Inherited from: DataManager
crosspostmessage: MessageResolvable) : Promise<Message> (
Publishes a message in an announcement channel to all channels following it, even if it's not cached.
deletemessage: MessageResolvable) : Promise<void> (
Deletes a message, even if it's not cached.
editmessage: MessageResolvableoptions: string | MessagePayload | MessageEditOptions) : Promise<Message<InGuild>> (
Edits a message, even if it's not cached.
fetchoptions: MessageResolvable | FetchMessageOptions) : Promise<Message<InGuild>> (
Fetches message(s) from a 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.
// Fetch a message
channel.messages.fetch('99539446449315840')
.then(message => console.log(message.content))
.catch(console.error);
// Fetch a maximum of 10 messages without caching
channel.messages.fetch({ limit: 10, cache: false })
.then(messages => console.log(`Received ${messages.size} messages`))
.catch(console.error);
// Fetch a maximum of 10 messages without caching around a message id
channel.messages.fetch({ limit: 10, cache: false, around: '99539446449315840' })
.then(messages => console.log(`Received ${messages.size} messages`))
.catch(console.error);
// Fetch messages and filter by a user id
channel.messages.fetch()
.then(messages => console.log(`${messages.filter(message =>
message.author.id === '84484653687267328').size} messages`))
.catch(console.error);
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.
// Get pinned messages
channel.messages.fetchPinned()
.then(messages => console.log(`Received ${messages.size} messages`))
.catch(console.error);
fetchPollAnswerVotersoptions: FetchPollAnswerVotersOptions) : Promise<Collection<Snowflake, User>> (
Fetches the users that voted for a poll answer.
pinmessage: MessageResolvablereason?: string) : Promise<void> (
Pins a message to the channel's pinned messages, even if it's not cached.
reactmessage: MessageResolvableemoji: EmojiIdentifierResolvable) : Promise<void> (
Adds a reaction to a message, even if it's not cached.
resolvemessage: MessageResolvable) : Message | null (
Resolves a MessageResolvable to a Message object.
resolveIdmessage: MessageResolvable) : Snowflake | null (
Resolves a MessageResolvable to a Message id.
unpinmessage: MessageResolvablereason?: string) : Promise<void> (
Unpins a message from the channel's pinned messages, even if it's not cached.
valueOfCollection<Key, Holds> () :
Inherited from: DataManager