mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
fix(CachedManager): allow overriding constructor for makeCache (#9763)
* fix(CachedManager): allow overriding constructor for makeCache * feat: allow determining makeCache based on non-overriden constructor * types: cleanup leftovers --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
15
packages/discord.js/typings/index.d.ts
vendored
15
packages/discord.js/typings/index.d.ts
vendored
@@ -4720,17 +4720,19 @@ export interface Caches {
|
||||
AutoModerationRuleManager: [manager: typeof AutoModerationRuleManager, holds: typeof AutoModerationRule];
|
||||
ApplicationCommandManager: [manager: typeof ApplicationCommandManager, holds: typeof ApplicationCommand];
|
||||
BaseGuildEmojiManager: [manager: typeof BaseGuildEmojiManager, holds: typeof GuildEmoji];
|
||||
DMMessageManager: [manager: typeof MessageManager, holds: typeof Message<false>];
|
||||
GuildEmojiManager: [manager: typeof GuildEmojiManager, holds: typeof GuildEmoji];
|
||||
// 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];
|
||||
GuildForumThreadManager: [manager: typeof GuildForumThreadManager, holds: typeof ThreadChannel];
|
||||
GuildForumThreadManager: [manager: typeof GuildForumThreadManager, holds: typeof ThreadChannel<true>];
|
||||
GuildInviteManager: [manager: typeof GuildInviteManager, holds: typeof Invite];
|
||||
GuildMessageManager: [manager: typeof GuildMessageManager, holds: typeof Message<true>];
|
||||
GuildScheduledEventManager: [manager: typeof GuildScheduledEventManager, holds: typeof GuildScheduledEvent];
|
||||
GuildStickerManager: [manager: typeof GuildStickerManager, holds: typeof Sticker];
|
||||
GuildTextThreadManager: [manager: typeof GuildTextThreadManager, holds: typeof ThreadChannel];
|
||||
GuildTextThreadManager: [manager: typeof GuildTextThreadManager, holds: typeof ThreadChannel<false>];
|
||||
MessageManager: [manager: typeof MessageManager, holds: typeof Message];
|
||||
// TODO: PermissionOverwriteManager: [manager: typeof PermissionOverwriteManager, holds: typeof PermissionOverwrites];
|
||||
PresenceManager: [manager: typeof PresenceManager, holds: typeof Presence];
|
||||
@@ -4748,11 +4750,18 @@ export type CacheConstructors = {
|
||||
[K in keyof Caches]: Caches[K][0] & { name: K };
|
||||
};
|
||||
|
||||
type OverriddenCaches =
|
||||
| 'DMMessageManager'
|
||||
| 'GuildForumThreadManager'
|
||||
| 'GuildMessageManager'
|
||||
| 'GuildTextThreadManager';
|
||||
|
||||
// This doesn't actually work the way it looks 😢.
|
||||
// Narrowing the type of `manager.name` doesn't propagate type information to `holds` and the return type.
|
||||
export type CacheFactory = (
|
||||
manager: CacheConstructors[keyof Caches],
|
||||
managerType: CacheConstructors[Exclude<keyof Caches, OverriddenCaches>],
|
||||
holds: Caches[(typeof manager)['name']][1],
|
||||
manager: CacheConstructors[keyof Caches],
|
||||
) => (typeof manager)['prototype'] extends DataManager<infer K, infer V, any> ? Collection<K, V> : never;
|
||||
|
||||
export type CacheWithLimitsOptions = {
|
||||
|
||||
Reference in New Issue
Block a user