GuildMessageManager

export class GuildMessageManager extends MessageManager<true>
export class GuildMessageManager extends MessageManager<true>
Manages API methods for messages in a guild and holds their cache.

Extends

MessageManager<true>
Readonly
cache:Collection<Key, Holds>
The cache of items for this manager.
Inherited from DataManager
The channel that the messages belong to
Readonly
client:Client
The client that instantiated this Manager
Inherited from BaseManager
Readonly
holds:Constructable<Holds>
The data structure belonging to this manager.
Inherited from DataManager
crosspost(message):Promise<Message<true>>
Publishes a message in an announcement channel to all channels following it, even if it's not cached.
NameTypeOptionalDescription
messageMessageResolvableNoThe message to publish
delete(message):Promise<void>
Deletes a message, even if it's not cached.
NameTypeOptionalDescription
messageMessageResolvableNoThe message to delete
Inherited from MessageManager
edit(message, options):Promise<Message<true>>
Edits a message, even if it's not cached.
NameTypeOptionalDescription
messageMessageResolvableNoThe message to edit
optionsstring | MessagePayload | MessageEditOptionsNoThe options to edit the message
Inherited from MessageManager
endPoll(messageId):Promise<Message>
Ends a poll.
NameTypeOptionalDescription
messageIdSnowflakeNoThe id of the message
Inherited from MessageManager
fetch(options):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.
Example
// Fetch a message
channel.messages.fetch('99539446449315840')
.then(message => console.log(message.content))
.catch(console.error);
// Fetch a message
channel.messages.fetch('99539446449315840')
.then(message => console.log(message.content))
.catch(console.error);
Example
// 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
channel.messages.fetch({ limit: 10, cache: false })
.then(messages => console.log(`Received ${messages.size} messages`))
.catch(console.error);
Example
// 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 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);
Example
// 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);
// 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);
NameTypeOptionalDescription
optionsMessageResolvable | FetchMessageOptionsNoOptions for fetching message(s)
fetchPinned(cache?):Promise<Collection<Snowflake, Message<true>>>
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.
Example
// Get pinned messages
channel.messages.fetchPinned()
.then(messages => console.log(`Received ${messages.size} messages`))
.catch(console.error);
// Get pinned messages
channel.messages.fetchPinned()
.then(messages => console.log(`Received ${messages.size} messages`))
.catch(console.error);
NameTypeOptionalDescription
cachebooleanYesWhether to cache the message(s)
Inherited from MessageManager
fetchPollAnswerVoters(options):Promise<Collection<Snowflake, User>>
Fetches the users that voted for a poll answer.
NameTypeOptionalDescription
optionsFetchPollAnswerVotersOptionsNoThe options for fetching the poll answer voters
Inherited from MessageManager
pin(message, reason?):Promise<void>
Pins a message to the channel's pinned messages, even if it's not cached.
NameTypeOptionalDescription
messageMessageResolvableNoThe message to pin
reasonstringYesReason for pinning
Inherited from MessageManager
react(message, emoji):Promise<void>
Adds a reaction to a message, even if it's not cached.
NameTypeOptionalDescription
messageMessageResolvableNoThe message to react to
emojiEmojiIdentifierResolvableNoThe emoji to react with
Inherited from MessageManager
resolve(message):Message | null
Resolves a MessageResolvable to a Message object.
NameTypeOptionalDescription
messageMessageResolvableNoThe message resolvable to resolve
Inherited from MessageManager
resolveId(message):Snowflake | null
Resolves a MessageResolvable to a Message id.
NameTypeOptionalDescription
messageMessageResolvableNoThe message resolvable to resolve
Inherited from MessageManager
unpin(message, reason?):Promise<void>
Unpins a message from the channel's pinned messages, even if it's not cached.
NameTypeOptionalDescription
messageMessageResolvableNoThe message to unpin
reasonstringYesReason for unpinning
Inherited from MessageManager
valueOf():Collection<Key, Holds>