mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +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.
|
||||
|
||||
10
typings/index.d.ts
vendored
10
typings/index.d.ts
vendored
@@ -2945,19 +2945,19 @@ export type BufferResolvable = Buffer | string;
|
||||
export interface Caches {
|
||||
ApplicationCommandManager: [manager: typeof ApplicationCommandManager, holds: typeof ApplicationCommand];
|
||||
BaseGuildEmojiManager: [manager: typeof BaseGuildEmojiManager, holds: typeof GuildEmoji];
|
||||
ChannelManager: [manager: typeof ChannelManager, holds: typeof Channel];
|
||||
GuildChannelManager: [manager: typeof GuildChannelManager, holds: typeof GuildChannel];
|
||||
GuildManager: [manager: typeof GuildManager, holds: typeof Guild];
|
||||
// TODO: ChannelManager: [manager: typeof ChannelManager, holds: typeof Channel];
|
||||
// TODO: GuildChannelManager: [manager: typeof GuildChannelManager, holds: typeof GuildChannel];
|
||||
// TODO: GuildManager: [manager: typeof GuildManager, holds: typeof Guild];
|
||||
GuildMemberManager: [manager: typeof GuildMemberManager, holds: typeof GuildMember];
|
||||
GuildBanManager: [manager: typeof GuildBanManager, holds: typeof GuildBan];
|
||||
GuildInviteManager: [manager: typeof GuildInviteManager, holds: typeof Invite];
|
||||
GuildStickerManager: [manager: typeof GuildStickerManager, holds: typeof Sticker];
|
||||
MessageManager: [manager: typeof MessageManager, holds: typeof Message];
|
||||
PermissionOverwriteManager: [manager: typeof PermissionOverwriteManager, holds: typeof PermissionOverwrites];
|
||||
// TODO: PermissionOverwriteManager: [manager: typeof PermissionOverwriteManager, holds: typeof PermissionOverwrites];
|
||||
PresenceManager: [manager: typeof PresenceManager, holds: typeof Presence];
|
||||
ReactionManager: [manager: typeof ReactionManager, holds: typeof MessageReaction];
|
||||
ReactionUserManager: [manager: typeof ReactionUserManager, holds: typeof User];
|
||||
RoleManager: [manager: typeof RoleManager, holds: typeof Role];
|
||||
// TODO: RoleManager: [manager: typeof RoleManager, holds: typeof Role];
|
||||
StageInstanceManager: [manager: typeof StageInstanceManager, holds: typeof StageInstance];
|
||||
ThreadManager: [manager: typeof ThreadManager, holds: typeof ThreadChannel];
|
||||
ThreadMemberManager: [manager: typeof ThreadMemberManager, holds: typeof ThreadMember];
|
||||
|
||||
Reference in New Issue
Block a user