mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
fix: remove support for overriding caches that break functionality (#6282)
Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
@@ -4,6 +4,8 @@ const CachedManager = require('./CachedManager');
|
||||
const Channel = require('../structures/Channel');
|
||||
const { Events, ThreadChannelTypes } = require('../util/Constants');
|
||||
|
||||
let cacheWarningEmitted = false;
|
||||
|
||||
/**
|
||||
* A manager of channels belonging to a client
|
||||
* @extends {CachedManager}
|
||||
@@ -11,6 +13,13 @@ const { Events, ThreadChannelTypes } = require('../util/Constants');
|
||||
class ChannelManager extends CachedManager {
|
||||
constructor(client, iterable) {
|
||||
super(client, Channel, iterable);
|
||||
if (!cacheWarningEmitted && this._cache.constructor.name !== 'Collection') {
|
||||
cacheWarningEmitted = true;
|
||||
process.emitWarning(
|
||||
`Overriding the cache handling for ${this.constructor.name} is unsupported and breaks functionality.`,
|
||||
'UnuspportedCacheOverwriteWarning',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,8 @@ const PermissionOverwrites = require('../structures/PermissionOverwrites');
|
||||
const ThreadChannel = require('../structures/ThreadChannel');
|
||||
const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants');
|
||||
|
||||
let cacheWarningEmitted = false;
|
||||
|
||||
/**
|
||||
* Manages API methods for GuildChannels and stores their cache.
|
||||
* @extends {CachedManager}
|
||||
@@ -16,6 +18,13 @@ const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants');
|
||||
class GuildChannelManager extends CachedManager {
|
||||
constructor(guild, iterable) {
|
||||
super(guild.client, GuildChannel, iterable);
|
||||
if (!cacheWarningEmitted && this._cache.constructor.name !== 'Collection') {
|
||||
cacheWarningEmitted = true;
|
||||
process.emitWarning(
|
||||
`Overriding the cache handling for ${this.constructor.name} is unsupported and breaks functionality.`,
|
||||
'UnuspportedCacheOverwriteWarning',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The guild this Manager belongs to
|
||||
|
||||
@@ -21,6 +21,8 @@ const Permissions = require('../util/Permissions');
|
||||
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
||||
const { resolveColor } = require('../util/Util');
|
||||
|
||||
let cacheWarningEmitted = false;
|
||||
|
||||
/**
|
||||
* Manages API methods for Guilds and stores their cache.
|
||||
* @extends {CachedManager}
|
||||
@@ -28,6 +30,13 @@ const { resolveColor } = require('../util/Util');
|
||||
class GuildManager extends CachedManager {
|
||||
constructor(client, iterable) {
|
||||
super(client, Guild, iterable);
|
||||
if (!cacheWarningEmitted && this._cache.constructor.name !== 'Collection') {
|
||||
cacheWarningEmitted = true;
|
||||
process.emitWarning(
|
||||
`Overriding the cache handling for ${this.constructor.name} is unsupported and breaks functionality.`,
|
||||
'UnuspportedCacheOverwriteWarning',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,8 @@ const PermissionOverwrites = require('../structures/PermissionOverwrites');
|
||||
const Role = require('../structures/Role');
|
||||
const { OverwriteTypes } = require('../util/Constants');
|
||||
|
||||
let cacheWarningEmitted = false;
|
||||
|
||||
/**
|
||||
* Manages API methods for guild channel permission overwrites and stores their cache.
|
||||
* @extends {CachedManager}
|
||||
@@ -14,6 +16,13 @@ const { OverwriteTypes } = require('../util/Constants');
|
||||
class PermissionOverwriteManager extends CachedManager {
|
||||
constructor(channel, iterable) {
|
||||
super(channel.client, PermissionOverwrites);
|
||||
if (!cacheWarningEmitted && this._cache.constructor.name !== 'Collection') {
|
||||
cacheWarningEmitted = true;
|
||||
process.emitWarning(
|
||||
`Overriding the cache handling for ${this.constructor.name} is unsupported and breaks functionality.`,
|
||||
'UnuspportedCacheOverwriteWarning',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The channel of the permission overwrite this manager belongs to
|
||||
|
||||
@@ -7,6 +7,8 @@ const Role = require('../structures/Role');
|
||||
const Permissions = require('../util/Permissions');
|
||||
const { resolveColor, setPosition } = require('../util/Util');
|
||||
|
||||
let cacheWarningEmitted = false;
|
||||
|
||||
/**
|
||||
* Manages API methods for roles and stores their cache.
|
||||
* @extends {CachedManager}
|
||||
@@ -14,6 +16,13 @@ const { resolveColor, setPosition } = require('../util/Util');
|
||||
class RoleManager extends CachedManager {
|
||||
constructor(guild, iterable) {
|
||||
super(guild.client, Role, iterable);
|
||||
if (!cacheWarningEmitted && this._cache.constructor.name !== 'Collection') {
|
||||
cacheWarningEmitted = true;
|
||||
process.emitWarning(
|
||||
`Overriding the cache handling for ${this.constructor.name} is unsupported and breaks functionality.`,
|
||||
'UnuspportedCacheOverwriteWarning',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The guild belonging to this manager
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
* (e.g. recommended shard count, shard count of the ShardingManager)
|
||||
* @property {CacheFactory} [makeCache] Function to create a cache.
|
||||
* You can use your own function, or the {@link Options} class to customize the Collection used for the cache.
|
||||
* <warn>Overriding the cache used in `GuildManager`, `ChannelManager`, 'GuildChannelManager', `RoleManager`,
|
||||
* and `PermissionOverwriteManager` is unsupported and **will** break functionality</warn>
|
||||
* @property {number} [messageCacheLifetime=0] DEPRECATED: Use `makeCache` with a `LimitedCollection` instead.
|
||||
* How long a message should stay in the cache until it is considered sweepable (in seconds, 0 for forever)
|
||||
* @property {number} [messageSweepInterval=0] DEPRECATED: Use `makeCache` with a `LimitedCollection` instead.
|
||||
|
||||
Reference in New Issue
Block a user