ChannelManager
Defined in: packages/managers/src/index.ts:75
Generic cache manager.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ChannelManager(
rest,options?):ChannelManager
Defined in: packages/managers/src/index.ts:85
Parameters
Section titled “Parameters”options?
Section titled “options?”allowedMentions?
Section titled “allowedMentions?”AllowedMentions
Default allowed_mentions for sends and edits without their own.
messageCache?
Section titled “messageCache?”Enables a bounded per-channel message cache; messages are not cached by default.
Returns
Section titled “Returns”ChannelManager
Overrides
Section titled “Overrides”Properties
Section titled “Properties”
readonlycache:Collection<string,Channel>
Defined in: packages/managers/src/base.ts:27
Authoritative resource state. Entries never expire: see Manager.set.
Inherited from
Section titled “Inherited from”Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get size():
number
Defined in: packages/managers/src/base.ts:105
Gets cache size.
Returns
Section titled “Returns”number
Number of cached values.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
IterableIterator<[string,Channel]>
Defined in: packages/managers/src/base.ts:121
Iterates cached entries.
Returns
Section titled “Returns”IterableIterator<[string, Channel]>
Cache iterator.
Inherited from
Section titled “Inherited from”addReaction()
Section titled “addReaction()”addReaction(
channelId,messageId,emoji):Promise<void>
Defined in: packages/managers/src/index.ts:425
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
string
Returns
Section titled “Returns”Promise<void>
bulkDeleteMessages()
Section titled “bulkDeleteMessages()”bulkDeleteMessages(
channelId,messageIds,reason?):Promise<void>
Defined in: packages/managers/src/index.ts:378
Bulk-deletes messages in a channel. Duplicate IDs are ignored and a single ID falls back to a normal delete.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageIds
Section titled “messageIds”Iterable<string>
reason?
Section titled “reason?”string
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If no IDs or more than 100 are provided, or any message is older than 14 days (Discord refuses to bulk-delete those).
cachedMessages()
Section titled “cachedMessages()”cachedMessages(
channelId):MessageManager|undefined
Defined in: packages/managers/src/index.ts:251
Returns the message manager for a channel only if one already exists.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”MessageManager | undefined
clear()
Section titled “clear()”clear():
void
Defined in: packages/managers/src/index.ts:651
Clears the cache.
Returns
Section titled “Returns”void
Nothing.
Overrides
Section titled “Overrides”create()
Section titled “create()”create(
guildId,options):Promise<Channel>
Defined in: packages/managers/src/index.ts:254
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
options
Section titled “options”Returns
Section titled “Returns”Promise<Channel>
createForumTag()
Section titled “createForumTag()”createForumTag(
channelId,tag,reason?):Promise<APIForumTag[]>
Defined in: packages/managers/src/index.ts:525
Adds a tag to a forum or media channel and returns the channel’s tags.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
reason?
Section titled “reason?”string
Audit-log reason.
Returns
Section titled “Returns”Promise<APIForumTag[]>
createThreadFromMessage()
Section titled “createThreadFromMessage()”createThreadFromMessage(
channelId,messageId,options):Promise<Channel>
Defined in: packages/managers/src/index.ts:617
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
options
Section titled “options”Returns
Section titled “Returns”Promise<Channel>
createWebhook()
Section titled “createWebhook()”createWebhook(
channelId,options):Promise<APIWebhook>
Defined in: packages/managers/src/index.ts:608
Creates a webhook in a channel.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
options
Section titled “options”Name, optional avatar data URI, and audit-log reason.
avatar?
Section titled “avatar?”string | null
string
reason?
Section titled “reason?”string
Returns
Section titled “Returns”Promise<APIWebhook>
crosspostMessage()
Section titled “crosspostMessage()”crosspostMessage(
channelId,messageId):Promise<Message>
Defined in: packages/managers/src/index.ts:364
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
Returns
Section titled “Returns”Promise<Message>
delete()
Section titled “delete()”delete(
channelId):boolean
Defined in: packages/managers/src/index.ts:291
Evicts a channel, dropping its per-channel message manager with it.
Overrides Manager.delete so cache eviction driven by a Gateway
CHANNEL_DELETE/THREAD_DELETE — which calls delete rather than
remove — releases the message manager and its cached
messages too, instead of retaining them for the client’s lifetime.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”boolean
Overrides
Section titled “Overrides”deleteCachedMessage()
Section titled “deleteCachedMessage()”deleteCachedMessage(
channelId,messageId):boolean
Defined in: packages/managers/src/index.ts:361
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
Returns
Section titled “Returns”boolean
deleteGuildChannels()
Section titled “deleteGuildChannels()”deleteGuildChannels(
guildId):number
Defined in: packages/managers/src/index.ts:193
Removes every cached channel that belongs to a guild.
Parameters
Section titled “Parameters”guildId
Section titled “guildId”string
Returns
Section titled “Returns”number
Number removed.
deleteMessage()
Section titled “deleteMessage()”deleteMessage(
channelId,messageId,reason?):Promise<void>
Defined in: packages/managers/src/index.ts:351
Deletes a message.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
reason?
Section titled “reason?”string
Audit-log reason (shown when deleting someone else’s message).
Returns
Section titled “Returns”Promise<void>
edit()
Section titled “edit()”edit(
channelId,options):Promise<Channel>
Defined in: packages/managers/src/index.ts:267
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
options
Section titled “options”Returns
Section titled “Returns”Promise<Channel>
editForumTag()
Section titled “editForumTag()”editForumTag(
channelId,tagId,changes,reason?):Promise<APIForumTag[]>
Defined in: packages/managers/src/index.ts:534
Changes a forum tag and returns the channel’s tags.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
string
changes
Section titled “changes”Partial<ForumTagInput>
reason?
Section titled “reason?”string
Returns
Section titled “Returns”Promise<APIForumTag[]>
editMessage()
Section titled “editMessage()”editMessage(
channelId,messageId,options):Promise<Message>
Defined in: packages/managers/src/index.ts:336
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
options
Section titled “options”Returns
Section titled “Returns”Promise<Message>
endPoll()
Section titled “endPoll()”endPoll(
channelId,messageId):Promise<Message>
Defined in: packages/managers/src/index.ts:204
Ends a poll now; returns the updated message.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
Returns
Section titled “Returns”Promise<Message>
fetch()
Section titled “fetch()”fetch(
channelId):Promise<Channel>
Defined in: packages/managers/src/index.ts:158
Fetches a channel; concurrent fetches share a request and a stale result never overwrites newer state.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”Promise<Channel>
fetchMessage()
Section titled “fetchMessage()”fetchMessage(
channelId,messageId,options?):Promise<Message>
Defined in: packages/managers/src/index.ts:301
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
options?
Section titled “options?”MessageFetchOptions = {}
Returns
Section titled “Returns”Promise<Message>
fetchMessages()
Section titled “fetchMessages()”fetchMessages(
channelId,query):Promise<Message[]>
Defined in: packages/managers/src/index.ts:309
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Iterable<string, any, any> | MessageQueryOptions
Returns
Section titled “Returns”Promise<Message[]>
fetchPage()
Section titled “fetchPage()”fetchPage(
channelId,options?):Promise<{after?:string;before?:string;hasMore:boolean;messages:Message[]; }>
Defined in: packages/managers/src/index.ts:630
Fetches a page of messages with cursor metadata.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Channel to fetch from.
options?
Section titled “options?”MessageQueryOptions = {}
Page options — before, after, around, and limit (max 100).
Returns
Section titled “Returns”Promise<{ after?: string; before?: string; hasMore: boolean; messages: Message[]; }>
{ messages, before, after, hasMore } — use before or after as cursors for the next page.
fetchPinnedMessages()
Section titled “fetchPinnedMessages()”fetchPinnedMessages(
channelId):Promise<Message[]>
Defined in: packages/managers/src/index.ts:483
Fetches the newest pinned messages (one page, up to 50, like the endpoint it replaces).
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”Promise<Message[]>
fetchPins()
Section titled “fetchPins()”fetchPins(
channelId,options?):Promise<{hasMore:boolean;messages:Message[]; }>
Defined in: packages/managers/src/index.ts:492
Fetches pinned messages a page at a time, newest first (limit 1-50, before an ISO timestamp from the previous page).
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
options?
Section titled “options?”before?
Section titled “before?”string
limit?
Section titled “limit?”number
Returns
Section titled “Returns”Promise<{ hasMore: boolean; messages: Message[]; }>
fetchPollVoters()
Section titled “fetchPollVoters()”fetchPollVoters(
channelId,messageId,answerId,options?):Promise<User[]>
Defined in: packages/managers/src/index.ts:215
Fetches users who voted for one poll answer.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
answerId
Section titled “answerId”number
options?
Section titled “options?”after?
Section titled “after?”string
limit?
Section titled “limit?”number
1-100 (default 25).
Returns
Section titled “Returns”Promise<User[]>
fetchReactions()
Section titled “fetchReactions()”fetchReactions(
channelId,messageId,emoji,options?):Promise<User[]>
Defined in: packages/managers/src/index.ts:437
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
string
options?
Section titled “options?”ReactionFetchOptions = {}
Returns
Section titled “Returns”Promise<User[]>
find()
Section titled “find()”find(
predicate):Channel|undefined
Defined in: packages/managers/src/base.ts:117
Finds a cached value.
Parameters
Section titled “Parameters”predicate
Section titled “predicate”(value, key) => boolean
Predicate.
Returns
Section titled “Returns”Channel | undefined
Matching value.
Inherited from
Section titled “Inherited from”first()
Section titled “first()”first():
Channel|undefined
Defined in: packages/managers/src/base.ts:109
Gets the first cached value.
Returns
Section titled “Returns”Channel | undefined
First value.
Inherited from
Section titled “Inherited from”get(
id):Channel|undefined
Defined in: packages/managers/src/base.ts:36
Gets a cached value.
Parameters
Section titled “Parameters”string
Cache key.
Returns
Section titled “Returns”Channel | undefined
Cached value.
Inherited from
Section titled “Inherited from”has(
id):boolean
Defined in: packages/managers/src/base.ts:40
Checks whether a value is cached.
Parameters
Section titled “Parameters”string
Cache key.
Returns
Section titled “Returns”boolean
True when cached.
Inherited from
Section titled “Inherited from”iterateMessages()
Section titled “iterateMessages()”iterateMessages(
channelId,options?):AsyncGenerator<Message,void,undefined>
Defined in: packages/managers/src/index.ts:408
Iterates a channel’s history newest-first, 100 messages per request,
starting before before (or the latest message) and stopping after
limit messages or at the start of the channel.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
options?
Section titled “options?”before?
Section titled “before?”string
limit?
Section titled “limit?”number
Returns
Section titled “Returns”AsyncGenerator<Message, void, undefined>
messages()
Section titled “messages()”messages(
channelId):MessageManager
Defined in: packages/managers/src/index.ts:121
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”permissionOverwrites()
Section titled “permissionOverwrites()”permissionOverwrites(
channelId):PermissionOverwriteManager
Defined in: packages/managers/src/index.ts:136
Permission overwrite manager for a channel.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”pinMessage()
Section titled “pinMessage()”pinMessage(
channelId,messageId,reason?):Promise<void>
Defined in: packages/managers/src/index.ts:585
Pins a message.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
reason?
Section titled “reason?”string
Audit-log reason.
Returns
Section titled “Returns”Promise<void>
remove()
Section titled “remove()”remove(
channelId,reason?):Promise<void>
Defined in: packages/managers/src/index.ts:282
Deletes a channel (or closes a DM).
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
reason?
Section titled “reason?”string
Audit-log reason.
Returns
Section titled “Returns”Promise<void>
removeAllReactions()
Section titled “removeAllReactions()”removeAllReactions(
channelId,messageId):Promise<void>
Defined in: packages/managers/src/index.ts:474
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
Returns
Section titled “Returns”Promise<void>
removeForumTag()
Section titled “removeForumTag()”removeForumTag(
channelId,tagId,reason?):Promise<APIForumTag[]>
Defined in: packages/managers/src/index.ts:552
Removes a forum tag and returns the channel’s remaining tags.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
string
reason?
Section titled “reason?”string
Returns
Section titled “Returns”Promise<APIForumTag[]>
removeOwnReaction()
Section titled “removeOwnReaction()”removeOwnReaction(
channelId,messageId,emoji):Promise<void>
Defined in: packages/managers/src/index.ts:455
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
string
Returns
Section titled “Returns”Promise<void>
removeReaction()
Section titled “removeReaction()”removeReaction(
channelId,messageId,emoji,userId):Promise<void>
Defined in: packages/managers/src/index.ts:464
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
string
userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<void>
resolve()
Section titled “resolve()”resolve(
channelId):Promise<Channel>
Defined in: packages/managers/src/index.ts:171
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”Promise<Channel>
send()
Section titled “send()”send(
channelId,options):Promise<Message>
Defined in: packages/managers/src/index.ts:295
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
options
Section titled “options”Returns
Section titled “Returns”Promise<Message>
sendSoundboardSound()
Section titled “sendSoundboardSound()”sendSoundboardSound(
channelId,options):Promise<void>
Defined in: packages/managers/src/index.ts:241
Plays a soundboard sound in a voice channel the bot is connected to.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
options
Section titled “options”soundId
Section titled “soundId”string
sourceGuildId?
Section titled “sourceGuildId?”string
Returns
Section titled “Returns”Promise<void>
set(
id,value):this
Defined in: packages/managers/src/base.ts:88
Stores a resource with setWithoutTTL(), so it leaves only on an explicit delete (e.g. a Gateway *_DELETE), never through TTL.
Parameters
Section titled “Parameters”string
Cache key.
Value.
Returns
Section titled “Returns”this
This manager.
Inherited from
Section titled “Inherited from”threads()
Section titled “threads()”threads(
channelId):ThreadManager
Defined in: packages/managers/src/index.ts:149
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”triggerTyping()
Section titled “triggerTyping()”triggerTyping(
channelId):Promise<void>
Defined in: packages/managers/src/index.ts:521
Shows “the bot is typing…” for about ten seconds, or until it sends a message.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”Promise<void>
unpinMessage()
Section titled “unpinMessage()”unpinMessage(
channelId,messageId,reason?):Promise<void>
Defined in: packages/managers/src/index.ts:597
Unpins a message.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
messageId
Section titled “messageId”string
reason?
Section titled “reason?”string
Audit-log reason.
Returns
Section titled “Returns”Promise<void>
update()
Section titled “update()”update(
channel):this
Defined in: packages/managers/src/index.ts:189
Parameters
Section titled “Parameters”channel
Section titled “channel”Returns
Section titled “Returns”this
upsert()
Section titled “upsert()”upsert(
data):Channel
Defined in: packages/managers/src/index.ts:174
Parameters
Section titled “Parameters”Returns
Section titled “Returns”upsertMessage()
Section titled “upsertMessage()”upsertMessage(
data):Message
Defined in: packages/managers/src/index.ts:331
Parameters
Section titled “Parameters”Returns
Section titled “Returns”values()
Section titled “values()”values():
Channel[]
Defined in: packages/managers/src/base.ts:113
Returns cached values.
Returns
Section titled “Returns”Channel[]
Array of values.