mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
feat: bypass cache check with forceFetch param (#4592)
This commit is contained in:
@@ -74,6 +74,7 @@ class ChannelManager extends BaseManager {
|
||||
* Obtains a channel from Discord, or the channel cache if it's already available.
|
||||
* @param {Snowflake} id ID of the channel
|
||||
* @param {boolean} [cache=true] Whether to cache the new channel object if it isn't already
|
||||
* @param {boolean} [force=false] Whether to skip the cache check and request the API
|
||||
* @returns {Promise<Channel>}
|
||||
* @example
|
||||
* // Fetch a channel by its id
|
||||
@@ -81,9 +82,11 @@ class ChannelManager extends BaseManager {
|
||||
* .then(channel => console.log(channel.name))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async fetch(id, cache = true) {
|
||||
const existing = this.cache.get(id);
|
||||
if (existing && !existing.partial) return existing;
|
||||
async fetch(id, cache = true, force = false) {
|
||||
if (!force) {
|
||||
const existing = this.cache.get(id);
|
||||
if (existing && !existing.partial) return existing;
|
||||
}
|
||||
|
||||
const data = await this.client.api.channels(id).get();
|
||||
return this.add(data, null, cache);
|
||||
|
||||
Reference in New Issue
Block a user