mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53: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 Channel = require('../structures/Channel');
|
||||||
const { Events, ThreadChannelTypes } = require('../util/Constants');
|
const { Events, ThreadChannelTypes } = require('../util/Constants');
|
||||||
|
|
||||||
|
let cacheWarningEmitted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A manager of channels belonging to a client
|
* A manager of channels belonging to a client
|
||||||
* @extends {CachedManager}
|
* @extends {CachedManager}
|
||||||
@@ -11,6 +13,13 @@ const { Events, ThreadChannelTypes } = require('../util/Constants');
|
|||||||
class ChannelManager extends CachedManager {
|
class ChannelManager extends CachedManager {
|
||||||
constructor(client, iterable) {
|
constructor(client, iterable) {
|
||||||
super(client, Channel, 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 ThreadChannel = require('../structures/ThreadChannel');
|
||||||
const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants');
|
const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants');
|
||||||
|
|
||||||
|
let cacheWarningEmitted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages API methods for GuildChannels and stores their cache.
|
* Manages API methods for GuildChannels and stores their cache.
|
||||||
* @extends {CachedManager}
|
* @extends {CachedManager}
|
||||||
@@ -16,6 +18,13 @@ const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants');
|
|||||||
class GuildChannelManager extends CachedManager {
|
class GuildChannelManager extends CachedManager {
|
||||||
constructor(guild, iterable) {
|
constructor(guild, iterable) {
|
||||||
super(guild.client, GuildChannel, 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
|
* The guild this Manager belongs to
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ const Permissions = require('../util/Permissions');
|
|||||||
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
||||||
const { resolveColor } = require('../util/Util');
|
const { resolveColor } = require('../util/Util');
|
||||||
|
|
||||||
|
let cacheWarningEmitted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages API methods for Guilds and stores their cache.
|
* Manages API methods for Guilds and stores their cache.
|
||||||
* @extends {CachedManager}
|
* @extends {CachedManager}
|
||||||
@@ -28,6 +30,13 @@ const { resolveColor } = require('../util/Util');
|
|||||||
class GuildManager extends CachedManager {
|
class GuildManager extends CachedManager {
|
||||||
constructor(client, iterable) {
|
constructor(client, iterable) {
|
||||||
super(client, Guild, 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 Role = require('../structures/Role');
|
||||||
const { OverwriteTypes } = require('../util/Constants');
|
const { OverwriteTypes } = require('../util/Constants');
|
||||||
|
|
||||||
|
let cacheWarningEmitted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages API methods for guild channel permission overwrites and stores their cache.
|
* Manages API methods for guild channel permission overwrites and stores their cache.
|
||||||
* @extends {CachedManager}
|
* @extends {CachedManager}
|
||||||
@@ -14,6 +16,13 @@ const { OverwriteTypes } = require('../util/Constants');
|
|||||||
class PermissionOverwriteManager extends CachedManager {
|
class PermissionOverwriteManager extends CachedManager {
|
||||||
constructor(channel, iterable) {
|
constructor(channel, iterable) {
|
||||||
super(channel.client, PermissionOverwrites);
|
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
|
* 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 Permissions = require('../util/Permissions');
|
||||||
const { resolveColor, setPosition } = require('../util/Util');
|
const { resolveColor, setPosition } = require('../util/Util');
|
||||||
|
|
||||||
|
let cacheWarningEmitted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages API methods for roles and stores their cache.
|
* Manages API methods for roles and stores their cache.
|
||||||
* @extends {CachedManager}
|
* @extends {CachedManager}
|
||||||
@@ -14,6 +16,13 @@ const { resolveColor, setPosition } = require('../util/Util');
|
|||||||
class RoleManager extends CachedManager {
|
class RoleManager extends CachedManager {
|
||||||
constructor(guild, iterable) {
|
constructor(guild, iterable) {
|
||||||
super(guild.client, Role, 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
|
* The guild belonging to this manager
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
* (e.g. recommended shard count, shard count of the ShardingManager)
|
* (e.g. recommended shard count, shard count of the ShardingManager)
|
||||||
* @property {CacheFactory} [makeCache] Function to create a cache.
|
* @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.
|
* 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.
|
* @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)
|
* 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.
|
* @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 {
|
export interface Caches {
|
||||||
ApplicationCommandManager: [manager: typeof ApplicationCommandManager, holds: typeof ApplicationCommand];
|
ApplicationCommandManager: [manager: typeof ApplicationCommandManager, holds: typeof ApplicationCommand];
|
||||||
BaseGuildEmojiManager: [manager: typeof BaseGuildEmojiManager, holds: typeof GuildEmoji];
|
BaseGuildEmojiManager: [manager: typeof BaseGuildEmojiManager, holds: typeof GuildEmoji];
|
||||||
ChannelManager: [manager: typeof ChannelManager, holds: typeof Channel];
|
// TODO: ChannelManager: [manager: typeof ChannelManager, holds: typeof Channel];
|
||||||
GuildChannelManager: [manager: typeof GuildChannelManager, holds: typeof GuildChannel];
|
// TODO: GuildChannelManager: [manager: typeof GuildChannelManager, holds: typeof GuildChannel];
|
||||||
GuildManager: [manager: typeof GuildManager, holds: typeof Guild];
|
// TODO: GuildManager: [manager: typeof GuildManager, holds: typeof Guild];
|
||||||
GuildMemberManager: [manager: typeof GuildMemberManager, holds: typeof GuildMember];
|
GuildMemberManager: [manager: typeof GuildMemberManager, holds: typeof GuildMember];
|
||||||
GuildBanManager: [manager: typeof GuildBanManager, holds: typeof GuildBan];
|
GuildBanManager: [manager: typeof GuildBanManager, holds: typeof GuildBan];
|
||||||
GuildInviteManager: [manager: typeof GuildInviteManager, holds: typeof Invite];
|
GuildInviteManager: [manager: typeof GuildInviteManager, holds: typeof Invite];
|
||||||
GuildStickerManager: [manager: typeof GuildStickerManager, holds: typeof Sticker];
|
GuildStickerManager: [manager: typeof GuildStickerManager, holds: typeof Sticker];
|
||||||
MessageManager: [manager: typeof MessageManager, holds: typeof Message];
|
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];
|
PresenceManager: [manager: typeof PresenceManager, holds: typeof Presence];
|
||||||
ReactionManager: [manager: typeof ReactionManager, holds: typeof MessageReaction];
|
ReactionManager: [manager: typeof ReactionManager, holds: typeof MessageReaction];
|
||||||
ReactionUserManager: [manager: typeof ReactionUserManager, holds: typeof User];
|
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];
|
StageInstanceManager: [manager: typeof StageInstanceManager, holds: typeof StageInstance];
|
||||||
ThreadManager: [manager: typeof ThreadManager, holds: typeof ThreadChannel];
|
ThreadManager: [manager: typeof ThreadManager, holds: typeof ThreadChannel];
|
||||||
ThreadMemberManager: [manager: typeof ThreadMemberManager, holds: typeof ThreadMember];
|
ThreadMemberManager: [manager: typeof ThreadMemberManager, holds: typeof ThreadMember];
|
||||||
|
|||||||
Reference in New Issue
Block a user