@wolfstar/plugin-gateway 0.8.0 → 0.9.0-next-20261002081721

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,11 @@
1
1
  import { Client, ClientOptions, Listener } from "@wolfstar/http-framework";
2
2
  import { OptionalWebSocketManagerOptions, ShardRange, WebSocketManager } from "@discordjs/ws";
3
3
  import { API, Client as Client$1 } from "@discordjs/core";
4
- import { Awaitable, Cache, CacheEntityName, CacheEntityTypes, CacheFactory, CachePolicies, EntityCache, GatewaySessionStore, IterableEntityCache } from "@wolfstar/plugin-cache";
4
+ import { Awaitable, Cache as Cache$1, CacheEntityName, CacheEntityTypes, CacheFactory, CachePolicies, EntityCache, GatewaySessionStore, IterableEntityCache } from "@wolfstar/plugin-cache";
5
5
  import { APIActionRowComponent, APIAllowedMentions, APIApplication, APIApplicationCommand, APIAttachment, APIAuditLogChange, APIAuthorizingIntegrationOwnersMap, APIAutoModerationAction, APIAutoModerationRule, APIAutoModerationRuleTriggerMetadata, APIAvatarDecorationData, APIButtonComponentWithCustomId, APIButtonComponentWithSKUId, APIButtonComponentWithURL, APIChannel, APIChannelMention, APIChannelSelectComponent, APICheckboxComponent, APICheckboxGroupComponent, APICheckboxGroupOption, APICollectibles, APIComponentInActionRow, APIComponentInMessageActionRow, APIContainerComponent, APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage, APIEmbedProvider, APIEmbedThumbnail, APIEmbedVideo, APIEmoji, APIEntitlement, APIExtendedInvite, APIFileComponent, APIFileUploadComponent, APIGuild, APIGuildForumDefaultReactionEmoji, APIGuildForumTag, APIGuildMember, APIGuildOnboarding, APIGuildOnboardingPrompt, APIGuildOnboardingPromptOption, APIGuildPreview, APIGuildScheduledEvent, APIGuildScheduledEventEntityMetadata, APIGuildScheduledEventRecurrenceRule, APIGuildScheduledEventRecurrenceRuleNWeekday, APIGuildWelcomeScreen, APIGuildWidget, APIGuildWidgetMember, APIIncidentsData, APIInviteChannel, APIInviteGuild, APILabelComponent, APIMediaGalleryComponent, APIMediaGalleryItem, APIMentionableSelectComponent, APIMessage, APIMessageActivity, APIMessageCall, APIMessageComponent, APIMessageComponentEmoji, APIMessageInteractionMetadata, APIMessageReference, APIMessageRoleSubscriptionData, APIMessageTopLevelComponent, APIModalComponent, APIOverwrite, APIPartialEmoji, APIPoll, APIPollAnswer, APIRadioGroupComponent, APIRadioGroupOption, APIReaction, APIRole, APIRoleSelectComponent, APIRoleTags, APISKU, APISectionComponent, APISelectMenuDefaultValue, APISelectMenuOption, APISeparatorComponent, APISoundboardSound, APIStageInstance, APISticker, APIStickerPack, APIStringSelectComponent, APISubscription, APITemplate, APITextDisplayComponent, APITextInputComponent, APIThreadChannel, APIThreadMember, APIThumbnailComponent, APIUnfurledMediaItem, APIUser, APIUserPrimaryGuild, APIUserSelectComponent, APIVoiceRegion, APIWebhook, ActivityFlags, ActivityType, AllowedMentionsTypes, ApplicationCommandOptionType, ApplicationFlags, AttachmentFlags, AuditLogEvent, AutoModerationActionType, AutoModerationRuleEventType, AutoModerationRuleKeywordPresetType, AutoModerationRuleTriggerType, ButtonStyle, ChannelFlags, ChannelType, FileUploadType, ForumLayoutType, GatewayActivity, GatewayActivityAssets, GatewayActivityUpdateData, GatewayAutoModerationActionExecutionDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayDispatchEvents, GatewayDispatchPayload, GatewayGuildDeleteDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildMemberRemoveDispatchData, GatewayGuildMembersChunkDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayGuildScheduledEventUserAddDispatchData, GatewayGuildScheduledEventUserRemoveDispatchData, GatewayGuildSoundboardSoundDeleteDispatchData, GatewayIntegrationDeleteDispatchData, GatewayIntentBits, GatewayInviteCreateDispatchData, GatewayInviteDeleteDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayMessageDeleteDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayPresenceClientStatus, GatewayPresenceUpdateData, GatewayRateLimitedDispatchData, GatewayReadyDispatchData, GatewayThreadDeleteDispatchData, GatewayThreadListSync, GatewayThreadMembersUpdateDispatchData, GatewayTypingStartDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GuildDefaultMessageNotifications, GuildExplicitContentFilter, GuildMemberFlags, GuildOnboardingMode, GuildOnboardingPromptType, GuildPremiumTier, GuildScheduledEventEntityType, GuildScheduledEventPrivacyLevel, GuildScheduledEventRecurrenceRuleFrequency, GuildScheduledEventRecurrenceRuleMonth, GuildScheduledEventRecurrenceRuleWeekday, GuildScheduledEventStatus, GuildSystemChannelFlags, GuildVerificationLevel, GuildWidgetStyle, InteractionType, InviteTargetType, InviteType, Locale, MessageActivityType, MessageFlags, MessageReferenceType, NameplatePalette, OverwriteType, PermissionFlagsBits, PollLayoutType, PresenceUpdateReceiveStatus, PresenceUpdateStatus, RESTAPIPoll, RESTGetAPIGuildVanityUrlResult, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildJSONBody, RESTPostAPIApplicationCommandsJSONBody, RESTPostAPIChannelMessageJSONBody, RESTPostAPIGuildsJSONBody, ReactionType, RoleFlags, SelectMenuDefaultValueType, SeparatorSpacingSize, Snowflake, SortOrderType, StageInstancePrivacyLevel, StickerFormatType, ThreadAutoArchiveDuration, ThreadChannelType, UserFlags, VideoQualityMode } from "discord-api-types/v10";
6
6
  import { APIActualInvite, ActionRowComponent, Activity as Activity$1, ActivityFlagsBitField as ActivityFlagsBitField$1, AnnouncementChannel as AnnouncementChannel$1, AnnouncementThreadChannel as AnnouncementThreadChannel$1, Attachment as Attachment$1, AttachmentFlagsBitField as AttachmentFlagsBitField$1, AutoModerationRule as AutoModerationRule$1, BitField, BitField as BitField$1, BitFieldResolvable, BitFieldResolvable as BitFieldResolvable$1, CategoryChannel as CategoryChannel$1, Channel as Channel$1, ChannelFlagsBitField as ChannelFlagsBitField$1, ChannelSelectMenuComponent as ChannelSelectMenuComponent$1, Component as Component$1, ContainerComponent as ContainerComponent$1, DMChannel as DMChannel$1, Embed as Embed$1, Emoji as Emoji$1, FileComponent as FileComponent$1, FileUploadComponent as FileUploadComponent$1, ForumChannel as ForumChannel$1, GroupDMChannel as GroupDMChannel$1, InteractiveButtonComponent as InteractiveButtonComponent$1, Invite, LinkButtonComponent as LinkButtonComponent$1, MediaChannel as MediaChannel$1, MediaGalleryComponent as MediaGalleryComponent$1, MediaGalleryItem as MediaGalleryItem$1, MentionableSelectMenuComponent as MentionableSelectMenuComponent$1, Message as Message$1, MessageFlagsBitField as MessageFlagsBitField$1, Partialize, PermissionsBitField, Poll as Poll$1, PollAnswer as PollAnswer$1, PremiumButtonComponent as PremiumButtonComponent$1, Presence as Presence$1, PrivateThreadChannel as PrivateThreadChannel$1, PublicThreadChannel as PublicThreadChannel$1, Reaction, RoleSelectMenuComponent as RoleSelectMenuComponent$1, SectionComponent as SectionComponent$1, SeparatorComponent as SeparatorComponent$1, SoundboardSound as SoundboardSound$1, StageChannel as StageChannel$1, StageInstance as StageInstance$1, Sticker as Sticker$1, StickerPack as StickerPack$1, StringSelectMenuComponent as StringSelectMenuComponent$1, Structure as Structure$1, TextChannel as TextChannel$1, TextDisplayComponent as TextDisplayComponent$1, TextInputComponent as TextInputComponent$1, ThumbnailComponent as ThumbnailComponent$1, UnfurledMediaItem as UnfurledMediaItem$1, User as User$1, UserSelectMenuComponent as UserSelectMenuComponent$1, VoiceChannel as VoiceChannel$1, VoiceState as VoiceState$1, Webhook as Webhook$1 } from "@discordjs/structures";
7
7
  import { BaseImageURLOptions, EmojiURLOptions, ImageURLOptions, REST, RawFile } from "@discordjs/rest";
8
+ import { Collection, ReadonlyCollection } from "@discordjs/collection";
8
9
  //#region src/util/PermissionsBitField.d.ts
9
10
  /**
10
11
  * The name of any permission.
@@ -688,6 +689,229 @@ export declare class AutoModerationRule extends AutoModerationRule$1 {
688
689
  private editTrigger;
689
690
  }
690
691
  //#endregion
692
+ //#region src/util/cache.d.ts
693
+ /**
694
+ * The raw API data a {@link StructureMixin | structure} wraps.
695
+ */
696
+ type RawAPIType<Value extends StructureMixin<object>> = Value extends StructureMixin<infer Type> ? Type : never;
697
+ /**
698
+ * A function building a {@link StructureMixin | structure} out of its raw API data.
699
+ */
700
+ type StructureCreator<Value extends StructureMixin<object>, Raw extends RawAPIType<Value> = RawAPIType<Value>> = (data: Partial<Raw>) => Value;
701
+ /**
702
+ * Whether an {@link Awaitable} is a promise, rather than the value itself.
703
+ *
704
+ * @internal
705
+ */
706
+ declare function isPromiseLike<T>(value: Awaitable<T>): value is Promise<T>;
707
+ /**
708
+ * Waits for a list of {@link Awaitable}s like `Promise.all`, then calls a function with their values. Unlike
709
+ * `Promise.all`, it stays synchronous when none of them is a promise, which is what lets a synchronous cache build
710
+ * structures without awaiting them.
711
+ *
712
+ * @param values The values, some of which may be promises.
713
+ * @param callback The function to call with the values.
714
+ * @internal
715
+ */
716
+ declare function whenAll<const T extends readonly unknown[], R>(values: T, callback: (values: { -readonly [Index in keyof T]: Awaited<T[Index]>; }) => Awaitable<R>): Awaitable<R>;
717
+ /**
718
+ * Resolves the relations of a structure again from its current data, and assigns them to that same structure: what
719
+ * keeps a long-lived instance from holding the relations of the day it was built. Synchronous when `hydrate` is.
720
+ *
721
+ * @param value The structure.
722
+ * @param hydrate Builds a structure of the same data, with its relations.
723
+ * @returns The structure it was given.
724
+ * @internal
725
+ */
726
+ declare function refreshRelations<Value extends StructureMixin<object>>(value: Value, hydrate: (data: RawAPIType<Value>) => Awaitable<StructureMixin<object>>): Awaitable<Value>;
727
+ /**
728
+ * Picks the cached structures of some IDs, in their order, skipping the ones that are not cached: the equivalent of
729
+ * the collections discord.js fills from its caches, e.g. `MessageMentions#channels`.
730
+ *
731
+ * @param ids The IDs.
732
+ * @param cached The cached structures, by ID.
733
+ * @internal
734
+ */
735
+ declare function pickCached<Value>(ids: readonly string[], cached: ReadonlyMap<string, Value> | undefined): Map<string, Value>;
736
+ /**
737
+ * Reads the cached structures of some IDs, synchronously when every read is, skipping duplicates and the IDs that
738
+ * are not cached. The {@link Awaitable} counterpart of discord.js's collections filled from its caches.
739
+ *
740
+ * @param ids The IDs.
741
+ * @param get Reads the structure of an ID.
742
+ * @internal
743
+ */
744
+ declare function whenCachedMap<Value>(ids: Iterable<string>, get: (id: string) => Awaitable<Value | null | undefined>): Awaitable<Map<string, Value>>;
745
+ /**
746
+ * The cache of a manager, as in the discord.js RFC #11426: it hands out {@link StructureMixin | structures}.
747
+ *
748
+ * @remarks
749
+ * Every method is {@link Awaitable}: synchronous on an in-memory cache ({@link Cache.synchronous}), a promise on a
750
+ * remote one. `await` works with both.
751
+ *
752
+ * @typeParam Value The structure the cache hands out.
753
+ * @typeParam Raw The raw API data the structure wraps.
754
+ */
755
+ interface Cache<Value extends StructureMixin<object>, Raw extends RawAPIType<Value> = RawAPIType<Value>> {
756
+ /**
757
+ * Whether every method answers synchronously, never with a promise.
758
+ */
759
+ readonly synchronous: boolean;
760
+ /**
761
+ * The function used to construct instances of the structure this cache holds.
762
+ */
763
+ readonly construct: StructureCreator<Value, Raw>;
764
+ /**
765
+ * Adds or updates data in the cache, returning the instantiated structure. If the item exists, it patches it with
766
+ * the new data unless `overwrite` is true. If it does not exist, it constructs a new instance and stores it.
767
+ */
768
+ add(data: Partial<Raw>, overwrite?: boolean): Awaitable<Value>;
769
+ /**
770
+ * Clears all items from the cache.
771
+ */
772
+ clear(): Awaitable<void>;
773
+ /**
774
+ * Deletes an item from the cache.
775
+ */
776
+ delete(key: string): Awaitable<boolean>;
777
+ /**
778
+ * Retrieves an item from the cache.
779
+ */
780
+ get(key: string): Awaitable<Value | undefined>;
781
+ /**
782
+ * Gets the number of items in the cache.
783
+ */
784
+ getSize(): Awaitable<number>;
785
+ /**
786
+ * Checks if an item exists in the cache.
787
+ */
788
+ has(key: string): Awaitable<boolean>;
789
+ /**
790
+ * Sets an item in the cache.
791
+ */
792
+ set(key: string, value: Value): Awaitable<this>;
793
+ }
794
+ /**
795
+ * The options of the cache of one entity, set per entity through the client's `cacheOptions` option.
796
+ */
797
+ interface CacheEntityOptions {
798
+ /**
799
+ * The maximum amount of entries the cache holds, the oldest one being evicted when a new one would exceed it. `0`
800
+ * holds nothing.
801
+ *
802
+ * @default Infinity
803
+ */
804
+ maxSize?: number;
805
+ }
806
+ /**
807
+ * What a {@link CacheConstructor} receives as its third argument: how the client keys and refreshes the entity, and
808
+ * the entity's `cacheOptions`.
809
+ */
810
+ interface CacheConstructorOptions<Value extends StructureMixin<object>, Raw extends RawAPIType<Value> = RawAPIType<Value>> extends CacheEntityOptions {
811
+ /**
812
+ * Gets the cache key of raw data. {@link Cache.add} must store under it: most entities are not keyed by their
813
+ * `id` alone (a member is keyed by its guild and user, a message by its channel and ID, ...).
814
+ */
815
+ keyOf: (data: Partial<Raw>) => string;
816
+ /**
817
+ * Resolves the relations of an instance again (e.g. `member.voice`), and returns that same instance. Call it on
818
+ * what {@link Cache.get} and {@link Cache.add} hand out, or long-lived instances keep the relations of the day
819
+ * they were built.
820
+ */
821
+ refresh: (value: Value) => Value;
822
+ }
823
+ /**
824
+ * A class building the {@link Cache} of an entity, as in the discord.js RFC #11426: what the client's
825
+ * `cacheConstructor` option takes. It is instantiated once per entity.
826
+ *
827
+ * @remarks
828
+ * The constructor receives `(creator, name, options)`:
829
+ *
830
+ * - `creator` builds a structure out of raw data, it is the cache's {@link Cache.construct};
831
+ * - `name` is the name of the entity, e.g. `"users"`;
832
+ * - `options` are the {@link CacheConstructorOptions}: `keyOf`, which `add` must key its entries with, `refresh`,
833
+ * to call on what `get` and `add` hand out, and the entity's `cacheOptions` (`maxSize`).
834
+ *
835
+ * Extending `CollectionCache` and forwarding the three arguments to `super` is the recommended way: it does all of
836
+ * the above. The cache must be synchronous.
837
+ *
838
+ * A cache that is not a `Map` cannot be enumerated, so what needs to list its entries does not work with it: the
839
+ * dispatch cascades (`GUILD_DELETE` and `CHANNEL_DELETE` leave the entries of the guild or channel behind), the
840
+ * reconciliation of the guilds left while offline on `READY`, the granular emoji and sticker diff events, and
841
+ * `listCached`.
842
+ *
843
+ * @example
844
+ * ```typescript
845
+ * class LoggingCache<
846
+ * Value extends StructureMixin<object>,
847
+ * Raw extends RawAPIType<Value> = RawAPIType<Value>,
848
+ * > extends CollectionCache<Value, Raw> {
849
+ * public override delete(key: string): boolean {
850
+ * console.log(`${this.name}: ${key} removed`);
851
+ * return super.delete(key);
852
+ * }
853
+ * }
854
+ *
855
+ * const client = new GatewayClient({ intents, cacheConstructor: LoggingCache });
856
+ * ```
857
+ */
858
+ type CacheConstructor = new <Value extends StructureMixin<object>>(creator: StructureCreator<Value>, name: CacheEntityName, options: CacheConstructorOptions<Value>) => Cache<Value>;
859
+ /**
860
+ * Reads what a {@link Cache} holds under a key as is: for a cache of instances (a `Map`, e.g. `CollectionCache`), the
861
+ * instance itself, without re-resolving its relations as `get` does. Other caches are read with `get`.
862
+ *
863
+ * @param cache The cache.
864
+ * @param key The key of the entry.
865
+ * @internal
866
+ */
867
+ declare function peekCache<Value extends StructureMixin<object>, Raw extends RawAPIType<Value> = RawAPIType<Value>>(cache: Cache<Value, Raw>, key: string): Awaitable<Value | undefined>;
868
+ //#endregion
869
+ //#region src/managers/BaseManager.d.ts
870
+ /**
871
+ * Manages the API methods of a data model, like discord.js's `BaseManager`.
872
+ */
873
+ export declare abstract class BaseManager {
874
+ /**
875
+ * The client that instantiated this manager.
876
+ */
877
+ readonly client: GatewayClient;
878
+ constructor(client: GatewayClient);
879
+ }
880
+ //#endregion
881
+ //#region src/managers/DataManager.d.ts
882
+ /**
883
+ * Manages the API methods of a data model along with a collection of instances, like discord.js's `DataManager`.
884
+ *
885
+ * @typeParam Value The structure this manager holds.
886
+ * @typeParam Args The arguments identifying an entity, e.g. `[id]` or `[guildId, userId]`.
887
+ */
888
+ export declare abstract class DataManager<Value extends StructureMixin<object>, Args extends readonly string[]> extends BaseManager {
889
+ /**
890
+ * The cache of the items this manager holds.
891
+ */
892
+ abstract readonly cache: Cache<Value>;
893
+ /**
894
+ * Gets the cache key of an entity, the one {@link DataManager.cache} takes.
895
+ *
896
+ * @param args The arguments identifying the entity.
897
+ */
898
+ abstract resolveKey(...args: Args): string;
899
+ /**
900
+ * Resolves a structure or a cache key to a structure.
901
+ *
902
+ * @param value A structure, returned as is, or the cache key of an entity (its ID, for managers keyed by ID).
903
+ * @returns The structure, or `null` if the key is not cached.
904
+ */
905
+ resolve(value: Value | string): Awaitable<Value | null>;
906
+ /**
907
+ * Resolves a structure or an ID to an ID.
908
+ *
909
+ * @param value A structure, or an ID.
910
+ * @returns The ID, or `null` if the value is neither.
911
+ */
912
+ resolveId(value: Value | string): string | null;
913
+ }
914
+ //#endregion
691
915
  //#region src/managers/CachedManager.d.ts
692
916
  /**
693
917
  * The options to fetch an entity with.
@@ -713,117 +937,94 @@ export interface AddOptions {
713
937
  /**
714
938
  * The cache key of the entity, when it cannot be derived from its data.
715
939
  */
716
- key?: string;
940
+ id?: string;
941
+ /**
942
+ * Extra arguments handed to the manager's `createStructure`.
943
+ */
944
+ extras?: unknown[];
717
945
  }
718
946
  /**
719
- * The base class of every manager, the `BaseManager` of the discord.js RFC #11426: it reads raw data from one of the
720
- * client's entity caches, falls back to the REST API when asked to, and wraps the result in a
721
- * {@link StructureMixin | structure} with {@link CachedManager.construct}.
947
+ * Manages the API methods of a data model with a mutable cache of instances: the `CachedManager` of the discord.js
948
+ * RFC #11426.
722
949
  *
723
950
  * @remarks
724
- * The cache only ever holds raw API data, building structures is always the manager's job. Without a store for its
725
- * entity (see the client's `makeCache`), `get` always resolves to `undefined` and `fetch` always hits the API.
726
- *
727
- * A failing store (e.g. Redis being unreachable) emits `cacheError` and, with the client's default
728
- * `cacheErrors: "miss"`, is treated as a cache miss.
729
- *
730
- * Every method is asynchronous since the cache can be Redis, except {@link CachedManager.cached}, which reads a
731
- * synchronous cache (`createInMemoryCache`) without awaiting it.
951
+ * Reads go through {@link CachedManager.cache}: `client.users.cache.get(id)`. The cache is built by the client's
952
+ * `cacheConstructor` (`CollectionCache` by default) and shared by every manager of the same entity.
732
953
  *
733
- * Like discord.js's `CachedManager`, every payload coming from the API goes through {@link CachedManager._add}, which
734
- * patches the cached entry and builds the structure. Structures are built by {@link CachedManager.hydrate}, which
735
- * resolves their relations (a message's author, a member's user, ...) from the cache, so they carry the latest known
736
- * data rather than the copy embedded in the payload.
954
+ * Caches keyed by more than an ID take the key built by `resolveKey`:
955
+ * `client.members.cache.get(client.members.resolveKey(guildId, userId))`.
737
956
  *
738
- * @typeParam Name The name of the entity cache this manager reads from.
957
+ * @typeParam Name The name of the entity this manager holds.
739
958
  * @typeParam Value The structure this manager builds.
740
959
  * @typeParam Args The arguments identifying an entity, e.g. `[id]` or `[guildId, userId]`.
741
960
  */
742
- export declare abstract class CachedManager<Name extends CacheEntityName, Value extends StructureMixin<object>, Args extends readonly string[]> {
743
- /**
744
- * The client this manager belongs to.
745
- */
746
- readonly client: GatewayClient;
961
+ export declare abstract class CachedManager<Name extends CacheEntityName, Value extends StructureMixin<object>, Args extends readonly string[]> extends DataManager<Value, Args> {
747
962
  /**
748
- * The name of the entity cache this manager reads from.
749
- */
750
- readonly entity: Name;
751
- constructor(client: GatewayClient, entity: Name);
752
- /**
753
- * The entity cache this manager reads from, or `undefined` when the client has no cache.
754
- */
755
- get cache(): EntityCache<CacheEntityTypes[Name]> | undefined;
756
- /**
757
- * Gets an entity from the cache.
758
- *
759
- * @param args The arguments identifying the entity.
760
- * @returns The entity, or `undefined` if it is not cached.
761
- */
762
- get(...args: Args): Promise<Value | undefined>;
763
- /**
764
- * Gets an entity from a synchronous cache, without awaiting it: the synchronous counterpart of
765
- * {@link CachedManager.get}, for hot paths such as message filters.
766
- *
767
- * @remarks
768
- * It builds the same structure as `get`, relations included, so the entity caches they are read from must be
769
- * synchronous too, which they all are with `createInMemoryCache`. `manager.cache?.synchronous` tells whether it can
770
- * be called.
771
- *
772
- * An asynchronous cache throws rather than returning `undefined`: it cannot tell whether the entity is cached, and
773
- * reporting a miss would silently skip whatever the caller does with cached entities, e.g. a filter.
963
+ * The cache of this manager's entity.
774
964
  *
775
965
  * @example
776
966
  * ```typescript
777
- * const member = client.members.cached(guildId, userId);
967
+ * const user = await client.users.cache.get(userId);
778
968
  * ```
779
- *
780
- * @param args The arguments identifying the entity.
781
- * @returns The entity, or `undefined` if it is not cached or the client has no cache.
782
- * @throws {TypeError} When the entity cache, or one of the caches its relations are read from, is asynchronous.
783
969
  */
784
- cached(...args: Args): Value | undefined;
970
+ readonly cache: Cache<Value>;
785
971
  /**
786
- * Gets an entity from the cache, synchronously when every cache it reads is: the {@link Awaitable} counterpart of
787
- * {@link CachedManager.get}, which both `get` and {@link CachedManager.cached} rely on.
788
- *
789
- * @param args The arguments identifying the entity.
790
- * @internal
972
+ * The name of the entity this manager holds.
791
973
  */
792
- _get(...args: Args): Awaitable<Value | undefined>;
974
+ protected readonly name: Name;
793
975
  /**
794
- * Resolves a structure or a cache key to a structure, like discord.js's `DataManager#resolve`.
976
+ * Wraps raw data in this manager's structure: the RFC's `StructureCreator`.
795
977
  *
796
- * @param value A structure, returned as is, or the cache key of an entity (its ID, for managers keyed by ID).
797
- * @returns The structure, or `null` if the key is not cached.
978
+ * @param data The raw data.
979
+ * @param extras The extra arguments passed to {@link CachedManager._add}.
980
+ */
981
+ protected abstract createStructure(data: CacheEntityTypes[Name], ...extras: unknown[]): Value;
982
+ constructor(client: GatewayClient, name: Name);
983
+ /**
984
+ * Gets {@link CachedManager.cache} from the client. Managers whose entity spans several caches override it.
798
985
  */
799
- resolve(value: Value | string): Promise<Value | null>;
986
+ protected createCache(): Cache<Value>;
800
987
  /**
801
- * Adds an API payload to the cache, patching the cached entry with it, and builds its structure. The counterpart of
802
- * discord.js's `CachedManager#_add`, asynchronous since the cache can be remote.
988
+ * The raw store of this manager's entity, or `undefined` when it is not cached.
989
+ */
990
+ protected get rawStore(): EntityCache<CacheEntityTypes[Name]> | undefined;
991
+ /**
992
+ * Adds an API payload to the cache and returns its structure, as in the RFC.
803
993
  *
804
994
  * @remarks
805
- * Like discord.js's `_patch`, the payload is shallowly merged into the cached entry, so the fields a partial payload
806
- * lacks keep their cached value. With `cache` set to `false`, the merged entry is built but not written.
995
+ * The payload is written with `cache.add`: a cached entry is patched and returned, and with a cache of instances
996
+ * (`CollectionCache`) that is the very instance the application may already hold. An entity that is not cached is
997
+ * built and stored.
807
998
  *
808
- * The merge is a read followed by a write, not an atomic operation: on a shared cache, a write landing in between
809
- * (another process, or a dispatch outside the guild's queue) is overwritten. `@wolfstar/plugin-cache` merges partial
810
- * dispatches the same way, and the fields at stake are refreshed by the next payload of the entity.
999
+ * With `cache` set to `false`, a patched clone is returned (or the entity is built) and the cache is left
1000
+ * untouched. The same goes for an entry the `filter` of the entity's policy rejects, whose cached entry is deleted
1001
+ * on top of that: a rejected update must not leave the outdated entry behind.
811
1002
  *
812
1003
  * @param data The raw data.
813
- * @param cache Whether to write the merged entry to the cache.
814
- * @param options The cache key, when it cannot be derived from the data.
1004
+ * @param cache Whether to write to the cache.
1005
+ * @param options The cache key, when it cannot be derived from the data, and the extras of `createStructure`.
815
1006
  * @internal
816
1007
  */
817
- _add(data: CacheEntityTypes[Name], cache?: boolean, { key }?: AddOptions): Promise<Value>;
1008
+ _add(data: CacheEntityTypes[Name], cache?: boolean, { id, extras }?: AddOptions): Promise<Value>;
818
1009
  /**
819
- * Gets the cached structure of the entity raw data describes, or builds one from the data when it is not cached.
820
- * Used to resolve the relations of other structures, e.g. a message's author.
1010
+ * Patches the cached entry of a key, if any, with the fields an endpoint answered without the entity itself.
821
1011
  *
822
- * @param data The raw data.
1012
+ * @remarks
1013
+ * Like every write of the managers, it follows the `filter` of the entity's policy: an entry whose patched data is
1014
+ * rejected is deleted from the cache.
1015
+ *
1016
+ * @param key The cache key of the entry.
1017
+ * @param patch The fields to patch, or a function computing them from the cached entry, `undefined` to leave it.
1018
+ * @internal
823
1019
  */
824
- resolveData(data: CacheEntityTypes[Name]): Promise<Value>;
1020
+ _patchCached(key: string, patch: Partial<CacheEntityTypes[Name]> | ((cached: Value) => Partial<CacheEntityTypes[Name]> | undefined)): Promise<void>;
1021
+ private accepts;
1022
+ private detached;
1023
+ private derivedKey;
1024
+ private resolveRelations;
825
1025
  /**
826
- * The {@link Awaitable} counterpart of {@link CachedManager.resolveData}, synchronous when every cache it reads is.
1026
+ * Gets the cached structure of the entity raw data describes, or builds one from the data when it is not cached.
1027
+ * Used to resolve the relations of other structures, e.g. a message's author. Synchronous when the cache is.
827
1028
  *
828
1029
  * @param data The raw data.
829
1030
  * @internal
@@ -832,29 +1033,39 @@ export declare abstract class CachedManager<Name extends CacheEntityName, Value
832
1033
  /**
833
1034
  * Gets a guild from the cache, to resolve the `guild` of a structure. Synchronous when the guild cache is.
834
1035
  *
835
- * @param guildId The ID of the guild, if the structure belongs to one.
836
1036
  * @remarks
837
1037
  * The guild does not resolve its own channel relations, see `GuildManager._getShallow`.
838
1038
  *
1039
+ * @param guildId The ID of the guild, if the structure belongs to one.
839
1040
  * @returns The guild, or `null` when there is no ID or the guild is not cached.
840
1041
  */
841
1042
  protected cachedGuild(guildId: string | null | undefined): Awaitable<Guild | null>;
842
1043
  /**
843
- * Builds the structure of raw data, resolving its relations from the cache. Without relations to resolve, the same
844
- * as {@link CachedManager.construct}.
1044
+ * Builds the structure of raw data, resolving its relations from the cache; synchronous when every cache the
1045
+ * relations are read from is. Without relations to resolve, the same as `createStructure`.
1046
+ *
1047
+ * @param data The raw data.
1048
+ * @param extras The extra arguments passed to {@link CachedManager._add}.
1049
+ * @internal
1050
+ */
1051
+ _hydrate(data: CacheEntityTypes[Name], ...extras: unknown[]): Awaitable<Value>;
1052
+ /**
1053
+ * Wraps raw data in this manager's structure, bound to this manager's client, without resolving its relations: the
1054
+ * creator handed to this entity's cache, always synchronous.
845
1055
  *
846
1056
  * @param data The raw data.
1057
+ * @param extras The extra arguments passed to {@link CachedManager._add}.
1058
+ * @internal
847
1059
  */
848
- hydrate(data: CacheEntityTypes[Name]): Promise<Value>;
1060
+ _construct(data: CacheEntityTypes[Name], ...extras: unknown[]): Value;
849
1061
  /**
850
- * The {@link Awaitable} counterpart of {@link CachedManager.hydrate}, synchronous when every cache the relations
851
- * are read from is. Managers resolving relations override this one, so `hydrate` and
852
- * {@link CachedManager.cached} build the same structures.
1062
+ * Builds the structure of raw data with {@link CachedManager._hydrate}, bound to this manager's client.
853
1063
  *
854
1064
  * @param data The raw data.
1065
+ * @param extras The extra arguments passed to {@link CachedManager._add}.
855
1066
  * @internal
856
1067
  */
857
- _hydrate(data: CacheEntityTypes[Name]): Awaitable<Value>;
1068
+ _build(data: CacheEntityTypes[Name], extras?: unknown[]): Awaitable<Value>;
858
1069
  /**
859
1070
  * Gets an entity from the cache, fetching it from the API (and caching it) on a cache miss.
860
1071
  *
@@ -874,32 +1085,12 @@ export declare abstract class CachedManager<Name extends CacheEntityName, Value
874
1085
  * @param args The arguments identifying the entity.
875
1086
  */
876
1087
  refresh(...args: Args): Promise<Value>;
877
- /**
878
- * Wraps raw data in this manager's structure: the RFC's `StructureCreator`, which lives on the manager since the
879
- * cache only holds raw data.
880
- *
881
- * @param data The raw data.
882
- */
883
- abstract construct(data: CacheEntityTypes[Name]): Value;
884
- /**
885
- * Wraps raw data in this manager's structure.
886
- *
887
- * @param data The raw data.
888
- * @deprecated Use {@link CachedManager.construct}.
889
- */
890
- createStructure(data: CacheEntityTypes[Name]): Value;
891
1088
  /**
892
1089
  * Gets the cache key of raw data.
893
1090
  *
894
1091
  * @param data The raw data.
895
1092
  */
896
1093
  abstract keyOf(data: CacheEntityTypes[Name]): string;
897
- /**
898
- * Gets the cache key of an entity.
899
- *
900
- * @param args The arguments identifying the entity.
901
- */
902
- abstract resolveKey(...args: Args): string;
903
1094
  /**
904
1095
  * Fetches the raw data of an entity from the API.
905
1096
  *
@@ -907,41 +1098,17 @@ export declare abstract class CachedManager<Name extends CacheEntityName, Value
907
1098
  */
908
1099
  protected abstract fetchRaw(...args: Args): Promise<CacheEntityTypes[Name]>;
909
1100
  /**
910
- * Writes raw data to the cache.
911
- *
912
- * @param key The cache key of the entity.
913
- * @param raw The raw data of the entity.
914
- */
915
- protected storeRaw(key: string, raw: CacheEntityTypes[Name]): Promise<void>;
916
- /**
917
- * Gets this manager's store when it can enumerate its entries, for the `listCached` methods.
1101
+ * Gets this entity's raw store when it can enumerate its entries, for the `listCached` methods.
918
1102
  *
919
1103
  * @returns The store, or `undefined` when this entity is not cached.
920
1104
  * @throws {TypeError} When the store cannot enumerate its entries.
921
1105
  */
922
1106
  protected iterableCache(): IterableEntityCache<CacheEntityTypes[Name]> | undefined;
923
1107
  /**
924
- * Gets an entity from the cache by its key, synchronously when every cache it reads is.
925
- *
926
- * @param key The cache key of the entity.
927
- */
928
- protected getByKey(key: string): Awaitable<Value | undefined>;
929
- /**
930
- * Runs a cache operation, reporting its failure through `cacheError`. With the client's `cacheErrors: "miss"`, a
931
- * failure resolves to `fallback`, otherwise it is rethrown. Synchronous when the operation is.
932
- *
933
- * @param operation The operation, for `cacheError`.
934
- * @param key The key of the entry, for `cacheError`.
935
- * @param run Runs the operation.
936
- * @param fallback What a failure resolves to under `cacheErrors: "miss"`.
1108
+ * Runs a raw store operation, reporting its failure through `cacheError`. With the client's `cacheErrors: "miss"`,
1109
+ * a failure resolves to `fallback`, otherwise it is rethrown. Synchronous when the operation is.
937
1110
  */
938
1111
  protected guard<T>(operation: CacheErrorContext["operation"], key: string | null, run: () => Awaitable<T>, fallback: T): Awaitable<T>;
939
- /**
940
- * Builds the structure of raw data with {@link CachedManager._hydrate}, bound to this manager's client.
941
- *
942
- * @param data The raw data.
943
- */
944
- protected build(data: CacheEntityTypes[Name]): Awaitable<Value>;
945
1112
  }
946
1113
  //#endregion
947
1114
  //#region src/managers/AutoModerationRuleManager.d.ts
@@ -979,7 +1146,7 @@ export interface AutoModerationRuleCreateOptions extends AutoModerationRuleEditO
979
1146
  export declare class AutoModerationRuleManager extends CachedManager<"autoModerationRules", AutoModerationRule, [ruleId: string]> {
980
1147
  readonly guildId: string;
981
1148
  constructor(client: GatewayClient, guildId: string);
982
- construct(data: CacheEntityTypes["autoModerationRules"]): AutoModerationRule;
1149
+ protected createStructure(data: CacheEntityTypes["autoModerationRules"]): AutoModerationRule;
983
1150
  keyOf(data: CacheEntityTypes["autoModerationRules"]): string;
984
1151
  resolveKey(ruleId: string): string;
985
1152
  _hydrate(data: CacheEntityTypes["autoModerationRules"]): Awaitable<AutoModerationRule>;
@@ -1085,8 +1252,7 @@ export interface ChannelPosition {
1085
1252
  /**
1086
1253
  * Manages the channels of one guild. Channels are cached by `client.channels`, which this manager writes to.
1087
1254
  */
1088
- export declare class GuildChannelManager {
1089
- readonly client: GatewayClient;
1255
+ export declare class GuildChannelManager extends BaseManager {
1090
1256
  readonly guildId: string;
1091
1257
  constructor(client: GatewayClient, guildId: string);
1092
1258
  /**
@@ -1458,7 +1624,7 @@ export interface ThreadMemberListOptions {
1458
1624
  */
1459
1625
  export declare class ThreadMemberManager extends CachedManager<"threadMembers", ThreadMember, [threadId: string, userId: string]> {
1460
1626
  constructor(client: GatewayClient);
1461
- construct(data: CacheEntityTypes["threadMembers"]): ThreadMember;
1627
+ protected createStructure(data: CacheEntityTypes["threadMembers"]): ThreadMember;
1462
1628
  keyOf(data: CacheEntityTypes["threadMembers"]): string;
1463
1629
  resolveKey(threadId: string, userId: string): string;
1464
1630
  /**
@@ -1510,8 +1676,7 @@ export declare class ThreadMemberManager extends CachedManager<"threadMembers",
1510
1676
  /**
1511
1677
  * Manages the members of one thread: `client.threadMembers`, with the thread's ID filled in.
1512
1678
  */
1513
- export declare class ThreadChannelMemberManager {
1514
- readonly client: GatewayClient;
1679
+ export declare class ThreadChannelMemberManager extends BaseManager {
1515
1680
  readonly threadId: string;
1516
1681
  constructor(client: GatewayClient, threadId: string);
1517
1682
  /**
@@ -1706,7 +1871,7 @@ export interface FetchedThreads {
1706
1871
  */
1707
1872
  export declare class ThreadManager extends CachedManager<"threads", AnyThreadChannel, [threadId: string]> {
1708
1873
  constructor(client: GatewayClient);
1709
- construct(data: CacheEntityTypes["threads"]): AnyThreadChannel;
1874
+ protected createStructure(data: CacheEntityTypes["threads"]): AnyThreadChannel;
1710
1875
  keyOf(data: CacheEntityTypes["threads"]): string;
1711
1876
  _hydrate(data: CacheEntityTypes["threads"]): Awaitable<AnyThreadChannel>;
1712
1877
  resolveKey(threadId: string): string;
@@ -1771,7 +1936,7 @@ export interface PinnedMessage {
1771
1936
  */
1772
1937
  export declare class MessageManager extends CachedManager<"messages", Message, [channelId: string, messageId: string]> {
1773
1938
  constructor(client: GatewayClient);
1774
- construct(data: CacheEntityTypes["messages"]): Message;
1939
+ protected createStructure(data: CacheEntityTypes["messages"]): Message;
1775
1940
  keyOf(data: CacheEntityTypes["messages"]): string;
1776
1941
  /**
1777
1942
  * Adds a message to the cache, its author to `client.users` (unless a webhook sent it), and its member to
@@ -1919,9 +2084,14 @@ export declare class MessageManager extends CachedManager<"messages", Message, [
1919
2084
  }): Promise<User[]>;
1920
2085
  protected fetchRaw(channelId: string, messageId: string): Promise<APIMessage>;
1921
2086
  private store;
1922
- private patchCached;
1923
2087
  }
1924
2088
  //#endregion
2089
+ //#region src/util/roles.d.ts
2090
+ /**
2091
+ * Several roles: an array of {@link RoleResolvable}s, or a `Collection` of roles, as discord.js takes them.
2092
+ */
2093
+ type RoleResolvables = readonly RoleResolvable[] | ReadonlyCollection<Snowflake, Role>;
2094
+ //#endregion
1925
2095
  //#region src/managers/GuildEmojiManager.d.ts
1926
2096
  /**
1927
2097
  * The options to create an emoji with.
@@ -1934,9 +2104,9 @@ export interface GuildEmojiCreateOptions {
1934
2104
  attachment: ImageResolvable;
1935
2105
  name: string;
1936
2106
  /**
1937
- * The IDs of the roles allowed to use the emoji, everyone when omitted.
2107
+ * The roles allowed to use the emoji, everyone when omitted: an array of roles or IDs, or a `Collection` of roles.
1938
2108
  */
1939
- roles?: readonly string[];
2109
+ roles?: RoleResolvables;
1940
2110
  reason?: string;
1941
2111
  }
1942
2112
  /**
@@ -1945,9 +2115,10 @@ export interface GuildEmojiCreateOptions {
1945
2115
  export interface GuildEmojiEditOptions {
1946
2116
  name?: string;
1947
2117
  /**
1948
- * The IDs of the roles allowed to use the emoji, `null` or empty for everyone.
2118
+ * The roles allowed to use the emoji, `null` or empty for everyone: an array of roles or IDs, or a `Collection`
2119
+ * of roles.
1949
2120
  */
1950
- roles?: readonly string[] | null;
2121
+ roles?: RoleResolvables | null;
1951
2122
  reason?: string;
1952
2123
  }
1953
2124
  /**
@@ -1959,7 +2130,7 @@ export declare class GuildEmojiManager extends CachedManager<"emojis", GuildEmoj
1959
2130
  */
1960
2131
  readonly guildId: string;
1961
2132
  constructor(client: GatewayClient, guildId: string);
1962
- construct(data: CacheEntityTypes["emojis"]): GuildEmoji;
2133
+ protected createStructure(data: CacheEntityTypes["emojis"]): GuildEmoji;
1963
2134
  keyOf(data: CacheEntityTypes["emojis"]): string;
1964
2135
  /**
1965
2136
  * Adds an emoji to the cache, and its uploader to `client.users`.
@@ -2026,18 +2197,37 @@ export declare class GuildEmojiManager extends CachedManager<"emojis", GuildEmoj
2026
2197
  //#endregion
2027
2198
  //#region src/managers/GuildEmojiRoleManager.d.ts
2028
2199
  /**
2029
- * Manages the roles allowed to use one custom emoji. When it has none, everyone can use it.
2200
+ * Manages the roles allowed to use one custom emoji, like discord.js's `GuildEmojiRoleManager`. When it has none,
2201
+ * everyone can use it.
2202
+ *
2203
+ * @remarks
2204
+ * {@link GuildEmojiRoleManager.cache} is `Awaitable`, unlike discord.js's: synchronous with the default in-memory
2205
+ * cache, a promise with a remote store.
2030
2206
  */
2031
- export declare class GuildEmojiRoleManager {
2032
- #private;
2033
- readonly client: GatewayClient;
2034
- readonly guildId: string;
2035
- readonly emojiId: string;
2036
- constructor(client: GatewayClient, guildId: string, emojiId: string, roleIds: readonly string[]);
2207
+ export declare class GuildEmojiRoleManager extends BaseManager {
2208
+ /**
2209
+ * The emoji these roles belong to.
2210
+ */
2211
+ readonly emoji: GuildEmoji;
2212
+ /**
2213
+ * @param emoji The emoji.
2214
+ */
2215
+ constructor(emoji: GuildEmoji);
2216
+ /**
2217
+ * The emoji's guild, from the cache: `null` when it is not cached.
2218
+ */
2219
+ get guild(): Guild | null;
2220
+ get guildId(): string;
2221
+ get emojiId(): string;
2037
2222
  /**
2038
2223
  * The IDs of the allowed roles.
2039
2224
  */
2040
2225
  get ids(): readonly string[];
2226
+ /**
2227
+ * The allowed roles held in the cache, by ID. Roles that are not cached are skipped: use
2228
+ * {@link GuildEmojiRoleManager.fetch} to get them all.
2229
+ */
2230
+ get cache(): Awaitable<Collection<Snowflake, Role>>;
2041
2231
  /**
2042
2232
  * Fetches the allowed roles, cache first.
2043
2233
  */
@@ -2045,21 +2235,29 @@ export declare class GuildEmojiRoleManager {
2045
2235
  /**
2046
2236
  * Allows more roles to use the emoji.
2047
2237
  *
2048
- * @param roles The ID of the role, or several IDs.
2238
+ * @param roleOrRoles The role or its ID, or an array or `Collection` of them.
2239
+ * @returns The emoji, patched.
2049
2240
  */
2050
- add(roles: string | readonly string[]): Promise<GuildEmoji>;
2241
+ add(roleOrRoles: RoleResolvable | RoleResolvables): Promise<GuildEmoji>;
2051
2242
  /**
2052
2243
  * Stops allowing roles to use the emoji.
2053
2244
  *
2054
- * @param roles The ID of the role, or several IDs.
2245
+ * @param roleOrRoles The role or its ID, or an array or `Collection` of them.
2246
+ * @returns The emoji, patched.
2055
2247
  */
2056
- remove(roles: string | readonly string[]): Promise<GuildEmoji>;
2248
+ remove(roleOrRoles: RoleResolvable | RoleResolvables): Promise<GuildEmoji>;
2057
2249
  /**
2058
2250
  * Replaces the allowed roles, everyone when empty.
2059
2251
  *
2060
- * @param roles The IDs of the roles.
2252
+ * @param roles The roles: an array of roles or IDs, or a `Collection` of roles.
2253
+ * @returns The emoji, patched.
2061
2254
  */
2062
- set(roles: readonly string[]): Promise<GuildEmoji>;
2255
+ set(roles: RoleResolvables): Promise<GuildEmoji>;
2256
+ /**
2257
+ * Creates another manager of the same emoji's roles.
2258
+ */
2259
+ clone(): GuildEmojiRoleManager;
2260
+ private resolve;
2063
2261
  }
2064
2262
  //#endregion
2065
2263
  //#region src/structures/emojis/GuildEmoji.d.ts
@@ -2134,8 +2332,7 @@ export declare class GuildEmoji extends Emoji<CacheEntityTypes["emojis"], GuildE
2134
2332
  /**
2135
2333
  * Manages the users who reacted to a message with one emoji.
2136
2334
  */
2137
- export declare class ReactionUserManager {
2138
- readonly client: GatewayClient;
2335
+ export declare class ReactionUserManager extends BaseManager {
2139
2336
  readonly channelId: string;
2140
2337
  readonly messageId: string;
2141
2338
  /**
@@ -2267,9 +2464,8 @@ export declare class MessageReaction extends Reaction<"count" | "count_details">
2267
2464
  /**
2268
2465
  * Manages the reactions of one message, as they were in the message's payload.
2269
2466
  */
2270
- export declare class ReactionManager {
2467
+ export declare class ReactionManager extends BaseManager {
2271
2468
  #private;
2272
- readonly client: GatewayClient;
2273
2469
  readonly channelId: string;
2274
2470
  readonly messageId: string;
2275
2471
  /**
@@ -3532,8 +3728,7 @@ export declare class Message extends Message$1<""> {
3532
3728
  /**
3533
3729
  * Manages the messages of one channel: `client.messages`, with the channel's ID filled in.
3534
3730
  */
3535
- export declare class ChannelMessageManager {
3536
- readonly client: GatewayClient;
3731
+ export declare class ChannelMessageManager extends BaseManager {
3537
3732
  readonly channelId: string;
3538
3733
  constructor(client: GatewayClient, channelId: string);
3539
3734
  /**
@@ -3702,9 +3897,8 @@ export interface PermissionOverwriteEditOptions {
3702
3897
  /**
3703
3898
  * Manages the permission overwrites of one channel, as they were in the channel's payload.
3704
3899
  */
3705
- export declare class PermissionOverwriteManager {
3900
+ export declare class PermissionOverwriteManager extends BaseManager {
3706
3901
  #private;
3707
- readonly client: GatewayClient;
3708
3902
  readonly channelId: string;
3709
3903
  readonly guildId: string | null;
3710
3904
  /**
@@ -3831,8 +4025,7 @@ export declare class CategoryChannel extends CategoryChannel$1 {
3831
4025
  /**
3832
4026
  * Manages the threads of one channel: `client.threads`, with the channel's ID filled in.
3833
4027
  */
3834
- export declare class ChannelThreadManager {
3835
- readonly client: GatewayClient;
4028
+ export declare class ChannelThreadManager extends BaseManager {
3836
4029
  readonly channelId: string;
3837
4030
  readonly guildId: string | null;
3838
4031
  constructor(client: GatewayClient, channelId: string, guildId: string | null);
@@ -4036,8 +4229,7 @@ export interface WebhookEditOptions {
4036
4229
  * Methods taking a webhook's token call the API with it rather than with the bot's authorization, so they work for
4037
4230
  * webhooks of other applications too.
4038
4231
  */
4039
- export declare class WebhookManager {
4040
- readonly client: GatewayClient;
4232
+ export declare class WebhookManager extends BaseManager {
4041
4233
  constructor(client: GatewayClient);
4042
4234
  /**
4043
4235
  * Fetches a webhook.
@@ -4314,7 +4506,7 @@ export interface GuildScheduledEventSubscriber {
4314
4506
  export declare class GuildScheduledEventManager extends CachedManager<"scheduledEvents", GuildScheduledEvent, [eventId: string]> {
4315
4507
  readonly guildId: string;
4316
4508
  constructor(client: GatewayClient, guildId: string);
4317
- construct(data: CacheEntityTypes["scheduledEvents"]): GuildScheduledEvent;
4509
+ protected createStructure(data: CacheEntityTypes["scheduledEvents"]): GuildScheduledEvent;
4318
4510
  keyOf(data: CacheEntityTypes["scheduledEvents"]): string;
4319
4511
  resolveKey(eventId: string): string;
4320
4512
  /**
@@ -4545,7 +4737,7 @@ export interface StageInstanceCreateOptions extends StageInstanceEditOptions {
4545
4737
  export declare class StageInstanceManager extends CachedManager<"stageInstances", StageInstance, [channelId: string]> {
4546
4738
  readonly guildId: string;
4547
4739
  constructor(client: GatewayClient, guildId: string);
4548
- construct(data: CacheEntityTypes["stageInstances"]): StageInstance;
4740
+ protected createStructure(data: CacheEntityTypes["stageInstances"]): StageInstance;
4549
4741
  keyOf(data: CacheEntityTypes["stageInstances"]): string;
4550
4742
  resolveKey(channelId: string): string;
4551
4743
  _hydrate(data: CacheEntityTypes["stageInstances"]): Awaitable<StageInstance>;
@@ -4686,7 +4878,7 @@ export interface SoundboardSoundCreateOptions extends SoundboardSoundEditOptions
4686
4878
  export declare class GuildSoundboardSoundManager extends CachedManager<"soundboardSounds", SoundboardSound, [soundId: string]> {
4687
4879
  readonly guildId: string;
4688
4880
  constructor(client: GatewayClient, guildId: string);
4689
- construct(data: CacheEntityTypes["soundboardSounds"]): SoundboardSound;
4881
+ protected createStructure(data: CacheEntityTypes["soundboardSounds"]): SoundboardSound;
4690
4882
  keyOf(data: CacheEntityTypes["soundboardSounds"]): string;
4691
4883
  resolveKey(soundId: string): string;
4692
4884
  /**
@@ -5215,7 +5407,7 @@ export declare class GuildStickerManager extends CachedManager<"stickers", Stick
5215
5407
  */
5216
5408
  readonly guildId: string;
5217
5409
  constructor(client: GatewayClient, guildId: string);
5218
- construct(data: CacheEntityTypes["stickers"]): Sticker;
5410
+ protected createStructure(data: CacheEntityTypes["stickers"]): Sticker;
5219
5411
  keyOf(data: CacheEntityTypes["stickers"]): string;
5220
5412
  /**
5221
5413
  * Adds a sticker to the cache, and its uploader to `client.users`.
@@ -5776,7 +5968,7 @@ export interface RolePosition {
5776
5968
  */
5777
5969
  export declare class RoleManager extends CachedManager<"roles", Role, [guildId: string, roleId: string]> {
5778
5970
  constructor(client: GatewayClient);
5779
- construct(data: CacheEntityTypes["roles"]): Role;
5971
+ protected createStructure(data: CacheEntityTypes["roles"]): Role;
5780
5972
  keyOf(data: CacheEntityTypes["roles"]): string;
5781
5973
  _hydrate(data: CacheEntityTypes["roles"]): Awaitable<Role>;
5782
5974
  resolveKey(guildId: string, roleId: string): string;
@@ -6019,28 +6211,68 @@ export declare class Role<Omitted extends keyof CacheEntityTypes["roles"] | "" =
6019
6211
  //#endregion
6020
6212
  //#region src/managers/GuildMemberRoleManager.d.ts
6021
6213
  /**
6022
- * Manages the roles of one {@link GuildMember}, reading them through the client's role manager.
6214
+ * Manages the roles of one {@link GuildMember}, like discord.js's `GuildMemberRoleManager`.
6023
6215
  *
6024
6216
  * @remarks
6025
- * discord.js's synchronous `member.roles.cache`, `highest`, `color`, ... become the `fetch*` methods here: the roles
6026
- * are read from the (possibly asynchronous) cache, falling back to the API.
6217
+ * The one deliberate difference from discord.js: {@link GuildMemberRoleManager.cache} and the getters reading it
6218
+ * (`highest`, `hoist`, `color`, ...) are `Awaitable`, like `manager.cache.get`. They are synchronous with the default
6219
+ * in-memory cache and a promise with a remote store, so `await` works with both.
6220
+ *
6221
+ * They only know the roles the cache holds. The `fetch*` methods fall back to the API when a role is not cached.
6027
6222
  */
6028
- export declare class GuildMemberRoleManager {
6029
- #private;
6030
- readonly client: GatewayClient;
6031
- readonly guildId: string;
6032
- readonly userId: string;
6223
+ export declare class GuildMemberRoleManager extends BaseManager {
6033
6224
  /**
6034
- * @param client The client.
6035
- * @param guildId The ID of the guild.
6036
- * @param userId The ID of the member's user.
6037
- * @param roleIds The IDs of the member's roles, as known to the member structure.
6225
+ * The member these roles belong to.
6226
+ */
6227
+ readonly member: GuildMember;
6228
+ /**
6229
+ * @param member The member.
6230
+ */
6231
+ constructor(member: GuildMember);
6232
+ /**
6233
+ * The member's guild, from the cache: `null` when it is not cached.
6234
+ */
6235
+ get guild(): Guild | null;
6236
+ get guildId(): string;
6237
+ /**
6238
+ * The ID of the member's user.
6239
+ *
6240
+ * @throws {GatewayError} `GuildMemberUserUnknown` when the member's payload did not include its user.
6038
6241
  */
6039
- constructor(client: GatewayClient, guildId: string, userId: string, roleIds: readonly string[]);
6242
+ get userId(): string;
6040
6243
  /**
6041
6244
  * The IDs of the member's roles, `@everyone` excluded.
6042
6245
  */
6043
6246
  get ids(): readonly string[];
6247
+ /**
6248
+ * The member's roles held in the cache, by ID, `@everyone` included. Roles that are not cached are skipped: use
6249
+ * {@link GuildMemberRoleManager.fetch} to get them all.
6250
+ */
6251
+ get cache(): Awaitable<Collection<Snowflake, Role>>;
6252
+ /**
6253
+ * The member's highest cached role. `null` when none of their roles is cached, `@everyone` included.
6254
+ */
6255
+ get highest(): Awaitable<Role | null>;
6256
+ /**
6257
+ * The cached role the member is displayed under in the member list, if any.
6258
+ */
6259
+ get hoist(): Awaitable<Role | null>;
6260
+ /**
6261
+ * The highest cached role giving the member a color, if any.
6262
+ */
6263
+ get color(): Awaitable<Role | null>;
6264
+ /**
6265
+ * The highest cached role giving the member an icon, if any.
6266
+ */
6267
+ get icon(): Awaitable<Role | null>;
6268
+ /**
6269
+ * The server booster role, if the member has it and it is cached.
6270
+ */
6271
+ get premiumSubscriberRole(): Awaitable<Role | null>;
6272
+ /**
6273
+ * The role Discord manages for the member, when the member is a bot and the role is cached.
6274
+ */
6275
+ get botRole(): Awaitable<Role | null>;
6044
6276
  /**
6045
6277
  * Fetches the member's roles, `@everyone` included, highest first.
6046
6278
  */
@@ -6070,26 +6302,43 @@ export declare class GuildMemberRoleManager {
6070
6302
  */
6071
6303
  fetchBotRole(): Promise<Role | null>;
6072
6304
  /**
6073
- * Adds roles to the member.
6305
+ * Adds a role, or several, to the member.
6306
+ *
6307
+ * @remarks
6308
+ * A single role goes through its own endpoint and resolves to a copy of the member with the role added. Several
6309
+ * roles replace the member's roles, like {@link GuildMemberRoleManager.set}.
6074
6310
  *
6075
- * @param roles The ID of the role, or several IDs.
6311
+ * @param roleOrRoles The role or its ID, or an array or `Collection` of them.
6076
6312
  * @param reason The reason for the audit log.
6313
+ * @returns The updated member.
6077
6314
  */
6078
- add(roles: string | readonly string[], reason?: string): Promise<void | GuildMember>;
6315
+ add(roleOrRoles: RoleResolvable | RoleResolvables, reason?: string): Promise<GuildMember>;
6079
6316
  /**
6080
- * Removes roles from the member.
6317
+ * Removes a role, or several, from the member.
6081
6318
  *
6082
- * @param roles The ID of the role, or several IDs.
6319
+ * @remarks
6320
+ * A single role goes through its own endpoint and resolves to a copy of the member with the role removed. Several
6321
+ * roles replace the member's roles, like {@link GuildMemberRoleManager.set}.
6322
+ *
6323
+ * @param roleOrRoles The role or its ID, or an array or `Collection` of them.
6083
6324
  * @param reason The reason for the audit log.
6325
+ * @returns The updated member.
6084
6326
  */
6085
- remove(roles: string | readonly string[], reason?: string): Promise<void | GuildMember>;
6327
+ remove(roleOrRoles: RoleResolvable | RoleResolvables, reason?: string): Promise<GuildMember>;
6086
6328
  /**
6087
6329
  * Replaces the member's roles.
6088
6330
  *
6089
- * @param roles The IDs of the roles the member ends up with.
6331
+ * @param roles The roles the member ends up with: an array of roles or IDs, or a `Collection` of roles.
6090
6332
  * @param reason The reason for the audit log.
6333
+ * @returns The member, patched.
6334
+ */
6335
+ set(roles: RoleResolvables, reason?: string): Promise<GuildMember>;
6336
+ /**
6337
+ * Creates another manager of the same member's roles.
6091
6338
  */
6092
- set(roles: readonly string[], reason?: string): Promise<GuildMember>;
6339
+ clone(): GuildMemberRoleManager;
6340
+ private fromCache;
6341
+ private resolveSingle;
6093
6342
  }
6094
6343
  //#endregion
6095
6344
  //#region src/structures/voice/VoiceState.d.ts
@@ -6268,7 +6517,7 @@ export declare class GuildMember extends Structure<CacheEntityTypes["members"]>
6268
6517
  */
6269
6518
  get roleIds(): readonly string[];
6270
6519
  /**
6271
- * The member's roles. It needs the member's user ID, which every payload but some partial ones carries.
6520
+ * The member's roles. Changing them needs the member's user ID, which every payload but some partial ones carries.
6272
6521
  */
6273
6522
  get roles(): GuildMemberRoleManager;
6274
6523
  get joinedTimestamp(): number | null;
@@ -6416,7 +6665,12 @@ export declare class GuildMember extends Structure<CacheEntityTypes["members"]>
6416
6665
  timeout(duration: number | null, reason?: string): Promise<this>;
6417
6666
  kick(reason?: string): Promise<this>;
6418
6667
  ban(options?: BanOptions): Promise<this>;
6419
- createDM(): Promise<DMChannel>;
6668
+ /**
6669
+ * Opens a direct message channel with the member, reusing the cached one.
6670
+ *
6671
+ * @param force Whether to skip the cache lookup and always call the API.
6672
+ */
6673
+ createDM(force?: boolean): Promise<DMChannel>;
6420
6674
  deleteDM(): Promise<DMChannel>;
6421
6675
  send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message>;
6422
6676
  /**
@@ -6453,9 +6707,9 @@ export interface GuildMemberEditOptions {
6453
6707
  */
6454
6708
  nick?: string | null;
6455
6709
  /**
6456
- * The IDs of the roles the member ends up with.
6710
+ * The roles the member ends up with: an array of roles or IDs, or a `Collection` of roles.
6457
6711
  */
6458
- roles?: readonly string[];
6712
+ roles?: RoleResolvables;
6459
6713
  mute?: boolean;
6460
6714
  deaf?: boolean;
6461
6715
  /**
@@ -6489,7 +6743,10 @@ export interface GuildMemberEditMeOptions {
6489
6743
  export interface GuildMemberAddOptions {
6490
6744
  accessToken: string;
6491
6745
  nick?: string;
6492
- roles?: readonly string[];
6746
+ /**
6747
+ * The roles the member starts with: an array of roles or IDs, or a `Collection` of roles.
6748
+ */
6749
+ roles?: RoleResolvables;
6493
6750
  mute?: boolean;
6494
6751
  deaf?: boolean;
6495
6752
  }
@@ -6579,7 +6836,7 @@ export interface GuildMembersRequestOptions {
6579
6836
  export declare class GuildMemberManager extends CachedManager<"members", GuildMember, [guildId: string, userId: string]> {
6580
6837
  #private;
6581
6838
  constructor(client: GatewayClient);
6582
- construct(data: CacheEntityTypes["members"]): GuildMember;
6839
+ protected createStructure(data: CacheEntityTypes["members"]): GuildMember;
6583
6840
  keyOf(data: CacheEntityTypes["members"]): string;
6584
6841
  /**
6585
6842
  * Adds a member to the cache, and its user to `client.users`.
@@ -6597,6 +6854,7 @@ export declare class GuildMemberManager extends CachedManager<"members", GuildMe
6597
6854
  * @internal
6598
6855
  */
6599
6856
  _hydrate(data: CacheEntityTypes["members"]): Awaitable<GuildMember>;
6857
+ private readRelation;
6600
6858
  resolveKey(guildId: string, userId: string): string;
6601
6859
  /**
6602
6860
  * Fetches the bot's own member in a guild.
@@ -6778,7 +7036,7 @@ export interface GuildBanListOptions {
6778
7036
  export declare class GuildBanManager extends CachedManager<"bans", GuildBan, [userId: string]> {
6779
7037
  readonly guildId: string;
6780
7038
  constructor(client: GatewayClient, guildId: string);
6781
- construct(data: CacheEntityTypes["bans"]): GuildBan;
7039
+ protected createStructure(data: CacheEntityTypes["bans"]): GuildBan;
6782
7040
  keyOf(data: CacheEntityTypes["bans"]): string;
6783
7041
  resolveKey(userId: string): string;
6784
7042
  /**
@@ -6907,7 +7165,7 @@ export declare class Integration extends Structure<CacheEntityTypes["integration
6907
7165
  export declare class GuildIntegrationManager extends CachedManager<"integrations", Integration, [integrationId: string]> {
6908
7166
  readonly guildId: string;
6909
7167
  constructor(client: GatewayClient, guildId: string);
6910
- construct(data: CacheEntityTypes["integrations"]): Integration;
7168
+ protected createStructure(data: CacheEntityTypes["integrations"]): Integration;
6911
7169
  keyOf(data: CacheEntityTypes["integrations"]): string;
6912
7170
  resolveKey(integrationId: string): string;
6913
7171
  /**
@@ -7228,7 +7486,7 @@ export declare class GuildInviteManager extends CachedManager<"invites", GuildIn
7228
7486
  */
7229
7487
  readonly guildId: string;
7230
7488
  constructor(client: GatewayClient, guildId: string);
7231
- construct(data: CacheEntityTypes["invites"]): GuildInvite;
7489
+ protected createStructure(data: CacheEntityTypes["invites"]): GuildInvite;
7232
7490
  keyOf(data: CacheEntityTypes["invites"]): string;
7233
7491
  /**
7234
7492
  * Adds an invite to the cache, and its inviter and target user to `client.users`.
@@ -7386,7 +7644,7 @@ export interface GuildOnboardingEditOptions {
7386
7644
  */
7387
7645
  export declare class GuildManager extends CachedManager<"guilds", Guild, [guildId: string]> {
7388
7646
  constructor(client: GatewayClient);
7389
- construct(data: CacheEntityTypes["guilds"]): Guild;
7647
+ protected createStructure(data: CacheEntityTypes["guilds"]): Guild;
7390
7648
  keyOf(data: CacheEntityTypes["guilds"]): string;
7391
7649
  /**
7392
7650
  * Builds a guild, resolving its AFK, system, widget, rules, public updates, and safety alerts channels from the
@@ -7606,8 +7864,7 @@ export interface GuildTemplateCreateGuildOptions {
7606
7864
  /**
7607
7865
  * Manages guild templates. Discord does not send them over the gateway, so they are never cached.
7608
7866
  */
7609
- export declare class GuildTemplateManager {
7610
- readonly client: GatewayClient;
7867
+ export declare class GuildTemplateManager extends BaseManager {
7611
7868
  constructor(client: GatewayClient);
7612
7869
  /**
7613
7870
  * Fetches a template by its code.
@@ -8339,9 +8596,16 @@ export declare class User extends User$1 {
8339
8596
  */
8340
8597
  guildTagBadgeURL(options?: BaseImageURLOptions): string | null;
8341
8598
  /**
8342
- * Opens a direct message channel with the user, or gets the existing one.
8599
+ * The cached direct message channel with the user, see `UserManager#dmChannel`: `null` when there is none, or when
8600
+ * the channel cache cannot be searched. Synchronous when the channel cache is.
8601
+ */
8602
+ get dmChannel(): Awaitable<DMChannel | null>;
8603
+ /**
8604
+ * Opens a direct message channel with the user, reusing the cached one.
8605
+ *
8606
+ * @param force Whether to skip the cache lookup and always call the API.
8343
8607
  */
8344
- createDM(): Promise<DMChannel>;
8608
+ createDM(force?: boolean): Promise<DMChannel>;
8345
8609
  /**
8346
8610
  * Closes the direct message channel with the user.
8347
8611
  */
@@ -9061,12 +9325,13 @@ export declare function createChannel(data: CacheEntityTypes["channels"], relati
9061
9325
  * Manages the channels known to the client, threads included.
9062
9326
  *
9063
9327
  * @remarks
9064
- * Threads live in their own entity cache, managed by `client.threads`, which {@link ChannelManager.get} falls back
9328
+ * Threads live in their own entity cache, managed by `client.threads`, which {@link ChannelManager.cache} falls back
9065
9329
  * to, so a thread ID resolves like any other channel ID.
9066
9330
  */
9067
9331
  export declare class ChannelManager extends CachedManager<"channels", AnyChannel, [channelId: string]> {
9068
9332
  constructor(client: GatewayClient);
9069
- construct(data: CacheEntityTypes["channels"]): AnyChannel;
9333
+ protected createCache(): Cache<AnyChannel>;
9334
+ protected createStructure(data: CacheEntityTypes["channels"]): AnyChannel;
9070
9335
  keyOf(data: CacheEntityTypes["channels"]): string;
9071
9336
  _hydrate(data: CacheEntityTypes["channels"]): Awaitable<AnyChannel>;
9072
9337
  /**
@@ -9090,27 +9355,26 @@ export declare class ChannelManager extends CachedManager<"channels", AnyChannel
9090
9355
  * @internal
9091
9356
  */
9092
9357
  _getInGuild(channelId: string, guild: Guild): Awaitable<AnyChannel | null>;
9093
- resolveKey(channelId: string): string;
9094
9358
  /**
9095
- * Adds a channel to the cache, handing threads to `client.threads`, whose cache holds them.
9359
+ * Finds the cached direct message channel with a user, for `client.users`.
9096
9360
  *
9097
- * @internal
9098
- */
9099
- _add(data: CacheEntityTypes["channels"], cache?: boolean, options?: AddOptions): Promise<AnyChannel>;
9100
- /**
9101
- * Gets a channel from the cache, looking it up in the thread cache as well, which `get` and `cached` rely on.
9361
+ * @remarks
9362
+ * Only a synchronous channel cache that can enumerate its entries is searched: scanning every channel of a remote
9363
+ * store costs more than asking Discord for the channel.
9102
9364
  *
9103
- * @param channelId The ID of the channel.
9365
+ * @param userId The ID of the user.
9366
+ * @returns The channel, `null` when the cache was searched and holds none, `undefined` when it cannot be searched.
9104
9367
  * @internal
9105
9368
  */
9106
- _get(channelId: string): Awaitable<AnyChannel | undefined>;
9369
+ _findDM(userId: string): Awaitable<DMChannel | null | undefined>;
9370
+ private readRaw;
9371
+ resolveKey(channelId: string): string;
9107
9372
  /**
9108
- * Writes a channel to the cache, threads to the thread cache.
9373
+ * Adds a channel to the cache, handing threads to `client.threads`, whose cache holds them.
9109
9374
  *
9110
- * @param channelId The ID of the channel.
9111
- * @param raw The raw channel.
9375
+ * @internal
9112
9376
  */
9113
- protected storeRaw(channelId: string, raw: CacheEntityTypes["channels"]): Promise<void>;
9377
+ _add(data: CacheEntityTypes["channels"], cache?: boolean, options?: AddOptions): Promise<AnyChannel>;
9114
9378
  /**
9115
9379
  * Edits a channel.
9116
9380
  *
@@ -9144,7 +9408,7 @@ export declare class ChannelManager extends CachedManager<"channels", AnyChannel
9144
9408
  */
9145
9409
  export declare class VoiceStateManager extends CachedManager<"voiceStates", VoiceState, [guildId: string, userId: string]> {
9146
9410
  constructor(client: GatewayClient);
9147
- construct(data: CacheEntityTypes["voiceStates"]): VoiceState;
9411
+ protected createStructure(data: CacheEntityTypes["voiceStates"]): VoiceState;
9148
9412
  keyOf(data: CacheEntityTypes["voiceStates"]): string;
9149
9413
  resolveKey(guildId: string, userId: string): string;
9150
9414
  _hydrate(data: CacheEntityTypes["voiceStates"]): Awaitable<VoiceState>;
@@ -9179,11 +9443,11 @@ export declare class VoiceStateManager extends CachedManager<"voiceStates", Voic
9179
9443
  *
9180
9444
  * @remarks
9181
9445
  * Presences only come from the gateway, with the `GuildPresences` intent: there is no API to fetch them, so `fetch`
9182
- * rejects on a cache miss. Use `get`, which resolves to `undefined` instead.
9446
+ * rejects on a cache miss. Use `cache.get`, which answers `undefined` instead.
9183
9447
  */
9184
9448
  export declare class PresenceManager extends CachedManager<"presences", Presence, [guildId: string, userId: string]> {
9185
9449
  constructor(client: GatewayClient);
9186
- construct(data: CacheEntityTypes["presences"]): Presence;
9450
+ protected createStructure(data: CacheEntityTypes["presences"]): Presence;
9187
9451
  keyOf(data: CacheEntityTypes["presences"]): string;
9188
9452
  resolveKey(guildId: string, userId: string): string;
9189
9453
  _hydrate(data: CacheEntityTypes["presences"]): Awaitable<Presence>;
@@ -9199,39 +9463,93 @@ export declare class PresenceManager extends CachedManager<"presences", Presence
9199
9463
  }
9200
9464
  //#endregion
9201
9465
  //#region src/managers/UserManager.d.ts
9466
+ /**
9467
+ * The options to open a direct message channel with.
9468
+ */
9469
+ export interface CreateDMOptions {
9470
+ /**
9471
+ * Whether to skip the cache lookup and always call the API.
9472
+ *
9473
+ * @default false
9474
+ */
9475
+ force?: boolean;
9476
+ /**
9477
+ * Whether to store the channel fetched from the API in the cache.
9478
+ *
9479
+ * @default true
9480
+ */
9481
+ cache?: boolean;
9482
+ }
9202
9483
  /**
9203
9484
  * Manages the {@link User}s known to the client.
9204
9485
  */
9205
9486
  export declare class UserManager extends CachedManager<"users", User, [userId: string]> {
9206
9487
  constructor(client: GatewayClient);
9207
- construct(data: CacheEntityTypes["users"]): User;
9488
+ protected createStructure(data: CacheEntityTypes["users"]): User;
9208
9489
  keyOf(data: CacheEntityTypes["users"]): string;
9209
9490
  resolveKey(userId: string): string;
9210
9491
  /**
9211
- * Opens a direct message channel with a user, or gets the existing one, and caches it.
9492
+ * Resolves a {@link UserResolvable} to a user: the user of a member or a thread member, the author of a message, or
9493
+ * the cached user of an ID.
9494
+ *
9495
+ * @param user The user, something holding one, or an ID.
9496
+ * @returns The user, or `null` if it is not known.
9497
+ */
9498
+ resolve(user: UserResolvable): Awaitable<User | null>;
9499
+ /**
9500
+ * Resolves a {@link UserResolvable} to a user ID.
9501
+ *
9502
+ * @param user The user, something holding one, or an ID.
9503
+ * @returns The ID, or `null` if the value holds none.
9504
+ */
9505
+ resolveId(user: UserResolvable): string | null;
9506
+ /**
9507
+ * Gets a user from the cache, fetching it from the API (and caching it) on a cache miss.
9508
+ *
9509
+ * @param user The user, something holding one, or an ID.
9510
+ * @param options Whether to skip the cache, and whether to store the result.
9511
+ */
9512
+ fetch(user: UserResolvable, options?: FetchOptions): Promise<User>;
9513
+ /**
9514
+ * Gets the cached direct message channel with a user.
9212
9515
  *
9213
9516
  * @remarks
9214
- * Discord returns the existing channel when there is one, so this always calls the API: unlike discord.js, there is
9215
- * no synchronous `dmChannel` lookup to try first.
9517
+ * It searches the channel cache, which only a synchronous cache that can enumerate its entries allows: the default
9518
+ * `CollectionCache` and the in-memory stores. Other caches (a Redis store, `cache: null`) answer `null`.
9216
9519
  *
9217
- * @param userId The ID of the user.
9520
+ * @param user The user, something holding one, or an ID.
9521
+ * @returns The channel, or `null` when there is none or the cache cannot be searched.
9218
9522
  */
9219
- createDM(userId: string): Promise<DMChannel>;
9523
+ dmChannel(user: UserResolvable): Awaitable<DMChannel | null>;
9524
+ /**
9525
+ * Opens a direct message channel with a user, and caches it. The cached channel is returned without calling the
9526
+ * API, unless `force` is set.
9527
+ *
9528
+ * @param user The user, something holding one, or an ID.
9529
+ * @param options Whether to skip the cache, and whether to store the result.
9530
+ */
9531
+ createDM(user: UserResolvable, { cache, force }?: CreateDMOptions): Promise<DMChannel>;
9220
9532
  /**
9221
9533
  * Closes the direct message channel with a user.
9222
9534
  *
9223
- * @param userId The ID of the user.
9535
+ * @remarks
9536
+ * When the channel cache cannot be searched (see {@link UserManager.dmChannel}), whether a channel exists is
9537
+ * unknown: Discord is asked for it first, and nothing is thrown.
9538
+ *
9539
+ * @param user The user, something holding one, or an ID.
9224
9540
  * @returns The closed channel.
9541
+ * @throws {GatewayError} `UserNoDMChannel` when the cache was searched and holds no channel with the user.
9225
9542
  */
9226
- deleteDM(userId: string): Promise<DMChannel>;
9543
+ deleteDM(user: UserResolvable): Promise<DMChannel>;
9227
9544
  /**
9228
9545
  * Sends a direct message to a user.
9229
9546
  *
9230
- * @param userId The ID of the user.
9547
+ * @param user The user, something holding one, or an ID.
9231
9548
  * @param options The message, or its content.
9232
9549
  */
9233
- send(userId: string, options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message>;
9550
+ send(user: UserResolvable, options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message>;
9234
9551
  protected fetchRaw(userId: string): Promise<import("discord-api-types/v10").APIUser>;
9552
+ private requireId;
9235
9553
  }
9236
9554
  //#endregion
9237
9555
  //#region src/structures/users/ClientUser.d.ts
@@ -9522,8 +9840,58 @@ export interface GatewayClientOptions extends ClientOptions, GatewayClientMessag
9522
9840
  */
9523
9841
  shardIds?: number[] | ShardRange | null;
9524
9842
  /**
9525
- * The cache to write every dispatch into, see `@wolfstar/plugin-cache`. Without one, the managers' `get` always
9526
- * resolve to `undefined`, update events receive `null` as their previous state, and `fetch` always hits the API.
9843
+ * Builds the cache of each entity, the one its managers expose as `manager.cache`: the `cacheConstructor` of the
9844
+ * discord.js RFC #11426. The caches hold structure instances, which dispatches patch in place.
9845
+ *
9846
+ * @remarks
9847
+ * The class is instantiated once per entity with `(creator, name, options)`, see {@link CacheConstructor}:
9848
+ * `options` carries `keyOf`, the key of raw data, which `add` must use since most entities are not keyed by their
9849
+ * `id`, `refresh`, to call on what `get` and `add` hand out so that relations are resolved again, and the entity's
9850
+ * {@link GatewayClientOptions.cacheOptions}. Extending {@link CollectionCache} is the recommended way.
9851
+ *
9852
+ * A cache that is not a `Map` cannot be enumerated: the dispatch cascades (`GUILD_DELETE`, `CHANNEL_DELETE`), the
9853
+ * reconciliation on `READY`, the emoji and sticker diff events, and `listCached` do not work with it.
9854
+ *
9855
+ * It cannot be combined with {@link GatewayClientOptions.cache} or {@link GatewayClientOptions.makeCache}, which
9856
+ * back the managers with raw `@wolfstar/plugin-cache` stores instead: passing both throws. `cache: null` wins over
9857
+ * it: nothing is cached, and the class is never instantiated.
9858
+ *
9859
+ * The structures of a cache of instances are built synchronously, so the caches their relations are read from
9860
+ * must be synchronous too.
9861
+ *
9862
+ * @default CollectionCache
9863
+ */
9864
+ cacheConstructor?: CacheConstructor;
9865
+ /**
9866
+ * The options of the cache of each entity, passed to {@link GatewayClientOptions.cacheConstructor} (the default
9867
+ * `CollectionCache` included) next to `keyOf` and `refresh`. `maxSize` bounds the amount of entries of an entity,
9868
+ * the oldest one being evicted first.
9869
+ *
9870
+ * @remarks
9871
+ * By default every received entity stays in memory until a dispatch removes it: this is what bounds it, next to
9872
+ * {@link GatewayClientOptions.policies} and `cache: null`.
9873
+ *
9874
+ * It only applies to caches built by a constructor. Like `cacheConstructor`, it cannot be combined with
9875
+ * {@link GatewayClientOptions.cache} or {@link GatewayClientOptions.makeCache}, whose stores have their own
9876
+ * bounds: passing both throws. With `cache: null` it is ignored.
9877
+ *
9878
+ * @example
9879
+ * ```typescript
9880
+ * // Keep the 1000 most recent messages, and no presence.
9881
+ * const client = new GatewayClient({
9882
+ * intents,
9883
+ * cacheOptions: { messages: { maxSize: 1_000 }, presences: { maxSize: 0 } },
9884
+ * });
9885
+ * ```
9886
+ *
9887
+ * @default undefined
9888
+ */
9889
+ cacheOptions?: Partial<Record<CacheEntityName, CacheEntityOptions>>;
9890
+ /**
9891
+ * A `@wolfstar/plugin-cache` cache (in memory or Redis) whose raw stores back the managers, instead of the
9892
+ * in-memory caches of instances built by {@link GatewayClientOptions.cacheConstructor}: structures are then built
9893
+ * on every read. `null` disables caching: the managers' `cache.get` always answer `undefined`, update events
9894
+ * receive `null` as their previous state, and `fetch` always hits the API.
9527
9895
  *
9528
9896
  * @remarks
9529
9897
  * Every entity cache is optional: an entity kind the cache does not hold is simply not cached, see
@@ -9531,11 +9899,12 @@ export interface GatewayClientOptions extends ClientOptions, GatewayClientMessag
9531
9899
  *
9532
9900
  * @default undefined
9533
9901
  */
9534
- cache?: Cache;
9902
+ cache?: Cache$1 | null;
9535
9903
  /**
9536
- * Creates the store of each entity kind, `null` or `undefined` not to cache it: the `CacheConstructor` of the
9537
- * discord.js RFC #11426. Called once per entity kind when the client is constructed, and takes precedence over
9538
- * {@link GatewayClientOptions.cache}.
9904
+ * Creates the raw `@wolfstar/plugin-cache` store of each entity kind, `null` or `undefined` not to cache it. Called
9905
+ * once per entity kind when the client is constructed, and takes precedence over
9906
+ * {@link GatewayClientOptions.cache}. Not to be confused with {@link GatewayClientOptions.cacheConstructor}, which
9907
+ * builds caches of structure instances.
9539
9908
  *
9540
9909
  * @example
9541
9910
  * ```typescript
@@ -9553,7 +9922,13 @@ export interface GatewayClientOptions extends ClientOptions, GatewayClientMessag
9553
9922
  makeCache?: CacheFactory;
9554
9923
  /**
9555
9924
  * The policies deciding which entries get cached, and for how long, per entity kind, see `withPolicy`. They apply to
9556
- * every write, from dispatches as well as from the managers.
9925
+ * every write, from dispatches as well as from the managers: an entry its `filter` rejects is not cached, and the
9926
+ * entry already cached under its key is deleted.
9927
+ *
9928
+ * @remarks
9929
+ * `ttl` only applies to `@wolfstar/plugin-cache` stores ({@link GatewayClientOptions.cache},
9930
+ * {@link GatewayClientOptions.makeCache}): the caches of instances built by
9931
+ * {@link GatewayClientOptions.cacheConstructor}, the default included, have no per-entry time-to-live.
9557
9932
  *
9558
9933
  * @example
9559
9934
  * ```typescript
@@ -9664,7 +10039,7 @@ export interface GatewayClientDestroyOptions {
9664
10039
  }
9665
10040
  /**
9666
10041
  * A {@link Client} that, on top of serving HTTP interactions, connects to the Discord gateway, writes every dispatch
9667
- * into an optional {@link Cache}, and emits {@link GatewayEventMap} events carrying structures.
10042
+ * into its cache, and emits {@link GatewayEventMap} events carrying structures.
9668
10043
  *
9669
10044
  * @example
9670
10045
  * ```typescript
@@ -9685,9 +10060,10 @@ export interface GatewayClientDestroyOptions {
9685
10060
  export declare class GatewayClient extends Client {
9686
10061
  #private;
9687
10062
  /**
9688
- * The cache every dispatch is written into, if any.
10063
+ * The raw cache every dispatch is written into, if any: the `@wolfstar/plugin-cache` cache passed as
10064
+ * {@link GatewayClientOptions.cache}, or a raw view of the managers' caches of instances.
9689
10065
  */
9690
- readonly cache: Cache | undefined;
10066
+ readonly cache: Cache$1 | undefined;
9691
10067
  /**
9692
10068
  * The REST manager the gateway (for its gateway bot info) and every manager's API calls go through, like
9693
10069
  * discord.js's `Client#rest`.
@@ -9783,6 +10159,30 @@ export declare class GatewayClient extends Client {
9783
10159
  * @internal
9784
10160
  */
9785
10161
  runInGuildOrder<Value>(guildId: string, task: () => Promise<Value>): Promise<Value>;
10162
+ /**
10163
+ * Gets the cache of an entity, building it on first use: the `CacheConstructor` of the discord.js RFC #11426.
10164
+ * Every manager of the same entity shares the same cache.
10165
+ *
10166
+ * @param creator Builds a structure from raw data, for entities the client does not know how to build.
10167
+ * @param name The name of the entity.
10168
+ */
10169
+ CacheConstructor<Value extends StructureMixin<object>>(creator: StructureCreator<Value>, name: CacheEntityName): Cache<Value>;
10170
+ /**
10171
+ * Runs a raw store operation, reporting its failure through `cacheError`, see
10172
+ * {@link GatewayClientOptions.cacheErrors}. Synchronous when the operation is.
10173
+ *
10174
+ * @internal
10175
+ */
10176
+ guardCache<T>(entity: CacheEntityName, operation: CacheErrorContext["operation"], key: string | null, run: () => Awaitable<T>, fallback: T): Awaitable<T>;
10177
+ /**
10178
+ * Gets the `filter` of an entity's policy the managers must apply themselves before writing to its cache, see
10179
+ * {@link GatewayClientOptions.policies}.
10180
+ *
10181
+ * @param name The name of the entity.
10182
+ * @returns The filter, or `undefined` when there is none or when the entity's store applies it already.
10183
+ * @internal
10184
+ */
10185
+ cacheFilter(name: CacheEntityName): ((value: object, key: string) => boolean) | undefined;
9786
10186
  /**
9787
10187
  * Resolves once every dispatch received so far has been processed.
9788
10188
  */
@@ -10017,7 +10417,7 @@ export interface CacheErrorContext {
10017
10417
  /**
10018
10418
  * The operation that failed.
10019
10419
  */
10020
- operation: "get" | "set" | "upsert" | "delete";
10420
+ operation: "get" | "set" | "upsert" | "delete" | "has" | "clear" | "getSize" | "keys" | "entries";
10021
10421
  }
10022
10422
  /**
10023
10423
  * What a reaction event says besides the reaction and the user.
@@ -10407,16 +10807,19 @@ export declare namespace EventGatewayListener {
10407
10807
  */
10408
10808
  export declare const GatewayErrorMessages: {
10409
10809
  readonly ClientSessionStoreConflict: "sessionStore replaces gateway.retrieveSessionInfo and gateway.updateSessionInfo, pass one or the other";
10810
+ readonly ClientCacheConflict: "cacheConstructor and cacheOptions cannot be combined with cache or makeCache, pass one or the other";
10410
10811
  readonly ClientNotConstructed: "No GatewayClient has been constructed yet";
10411
10812
  readonly DispatchHandlerConflict: (event: string) => string;
10412
10813
  readonly DispatchTimeout: (type: string, shardId: number, partition: string | null, timeout: number) => string;
10413
10814
  readonly SessionStoreFailed: (operation: "get" | "set", shardId: number) => string;
10414
10815
  readonly SessionStoreTimeout: (timeout: number) => string;
10415
10816
  readonly CacheAsynchronous: (entity: string) => string;
10416
- readonly CacheRelationsAsynchronous: (entity: string) => string;
10817
+ readonly CacheConstructorAsynchronous: (entity: string) => string;
10417
10818
  readonly CacheNotIterable: (entity: string) => string;
10418
10819
  readonly CacheKeyUnresolvable: (entity: string, reason: string) => string;
10419
10820
  readonly IdUnresolvable: "Cannot resolve an ID from a structure without one";
10821
+ readonly InvalidType: (name: string, expected: string, an?: boolean) => string;
10822
+ readonly InvalidElement: (type: string, name: string, element: unknown) => string;
10420
10823
  readonly ChannelGuildUnknown: (channelId: string) => string;
10421
10824
  readonly ChannelTypeChanged: (channelId: string, from: number, to: number) => string;
10422
10825
  readonly ChannelLockPermissionsConflict: "Pass either lockPermissions or permissionOverwrites, not both";
@@ -10436,6 +10839,7 @@ export declare const GatewayErrorMessages: {
10436
10839
  readonly GuildMembersRateLimited: (guildId: string, nonce: string, retryAfter: number) => string;
10437
10840
  readonly PresenceNotFetchable: (guildId: string, userId: string) => string;
10438
10841
  readonly InviteGuildUnknown: (code: string) => string;
10842
+ readonly UserNoDMChannel: "No DM Channel exists!";
10439
10843
  readonly EmojiEmpty: "Cannot resolve an empty string to an emoji";
10440
10844
  readonly EmojiType: "Cannot resolve an emoji without an ID nor a name";
10441
10845
  readonly NotGuildSticker: "Only guild stickers can be edited or deleted";
@@ -10528,49 +10932,159 @@ export declare class GroupDMInvite extends BaseInvite {}
10528
10932
  */
10529
10933
  export declare function createInvite(data: InviteData, relations?: InviteRelations): BaseInvite;
10530
10934
  //#endregion
10531
- //#region src/util/cache.d.ts
10935
+ //#region src/util/CollectionCache.d.ts
10532
10936
  /**
10533
- * The raw API data a {@link StructureMixin | structure} wraps.
10937
+ * The options of {@link CollectionCache}.
10534
10938
  */
10535
- type RawAPIType<Value extends StructureMixin<object>> = Value extends StructureMixin<infer Type> ? Type : never;
10939
+ export interface CollectionCacheOptions<Value, Raw> {
10940
+ /**
10941
+ * Gets the key of raw data, for {@link CollectionCache.add}.
10942
+ *
10943
+ * @default (data) => data.id
10944
+ */
10945
+ keyOf?: (data: Partial<Raw>) => string;
10946
+ /**
10947
+ * Called with an instance every time it is read with `get` or updated with `add`, to bring what it holds besides
10948
+ * its data (its relations) up to date. It returns the instance to hand out.
10949
+ */
10950
+ refresh?: (value: Value) => Value;
10951
+ /**
10952
+ * The maximum amount of entries, the oldest one being evicted when a new one would exceed it. `0` holds nothing:
10953
+ * `add` still builds the structure, without keeping it.
10954
+ *
10955
+ * @default Infinity
10956
+ */
10957
+ maxSize?: number;
10958
+ }
10536
10959
  /**
10537
- * A function building a {@link StructureMixin | structure} out of its raw API data.
10960
+ * The default {@link Cache}: an in-memory `Collection` of structure instances, like discord.js's caches.
10961
+ *
10962
+ * @remarks
10963
+ * `add` patches the cached instance in place, so a reference kept by the application sees later updates.
10964
+ *
10965
+ * Every method is synchronous. Being a `Collection`, it also has `find`, `filter`, `map`, ... which return plain
10966
+ * collections. Instances reached by iterating carry the relations of their last `get`.
10538
10967
  */
10539
- type StructureCreator<Value extends StructureMixin<object>, Raw extends RawAPIType<Value> = RawAPIType<Value>> = (data: Raw) => Value;
10968
+ export declare class CollectionCache<Value extends StructureMixin<object>, Raw extends RawAPIType<Value> = RawAPIType<Value>> extends Collection<string, Value> implements Cache<Value, Raw> {
10969
+ #private;
10970
+ static get [Symbol.species](): typeof Collection;
10971
+ readonly synchronous = true;
10972
+ readonly construct: StructureCreator<Value, Raw>;
10973
+ /**
10974
+ * The name of the entity this cache holds.
10975
+ */
10976
+ readonly name: CacheEntityName;
10977
+ constructor(creator: StructureCreator<Value, Raw>, name: CacheEntityName, options?: CollectionCacheOptions<Value, Raw>);
10978
+ add(data: Partial<Raw>, overwrite?: boolean): Value;
10979
+ get(key: string): Value | undefined;
10980
+ set(key: string, value: Value): this;
10981
+ getSize(): number;
10982
+ }
10983
+ //#endregion
10984
+ //#region src/util/EntityStoreCache.d.ts
10540
10985
  /**
10541
- * Whether an {@link Awaitable} is a promise, rather than the value itself.
10542
- *
10543
- * @internal
10986
+ * Runs a store operation, reporting its failure and resolving it to a fallback or rethrowing it.
10544
10987
  */
10545
- declare function isPromiseLike<T>(value: Awaitable<T>): value is Promise<T>;
10988
+ export type CacheGuard = <T>(operation: CacheErrorContext["operation"], key: string | null, run: () => Awaitable<T>, fallback: T) => Awaitable<T>;
10546
10989
  /**
10547
- * Waits for a list of {@link Awaitable}s like `Promise.all`, then calls a function with their values. Unlike
10548
- * `Promise.all`, it stays synchronous when none of them is a promise, which is what lets a synchronous cache build
10549
- * structures without awaiting them.
10550
- *
10551
- * @param values The values, some of which may be promises.
10552
- * @param callback The function to call with the values.
10553
- * @internal
10990
+ * The options of {@link EntityStoreCache}.
10554
10991
  */
10555
- declare function whenAll<const T extends readonly unknown[], R>(values: T, callback: (values: { -readonly [Index in keyof T]: Awaited<T[Index]>; }) => Awaitable<R>): Awaitable<R>;
10992
+ export interface EntityStoreCacheOptions<Value, Raw> {
10993
+ /**
10994
+ * The raw store.
10995
+ */
10996
+ store: EntityCache<Raw>;
10997
+ /**
10998
+ * Gets the key of raw data, for {@link EntityStoreCache.add}.
10999
+ */
11000
+ keyOf: (data: Partial<Raw>) => string;
11001
+ /**
11002
+ * Builds the structure of raw data read from the store, with its relations. May be asynchronous.
11003
+ *
11004
+ * @default The creator.
11005
+ */
11006
+ hydrate?: (data: Raw) => Awaitable<Value>;
11007
+ /**
11008
+ * Whether every method answers synchronously. The structures read their relations from other stores, so a view over
11009
+ * a synchronous store is only synchronous when those are too.
11010
+ *
11011
+ * @default () => store.synchronous === true
11012
+ */
11013
+ synchronous?: () => boolean;
11014
+ /**
11015
+ * Guards every store call.
11016
+ *
11017
+ * @default Lets errors through.
11018
+ */
11019
+ guard?: CacheGuard;
11020
+ }
10556
11021
  /**
10557
- * Picks the cached structures of some IDs, in their order, skipping the ones that are not cached: the equivalent of
10558
- * the collections discord.js fills from its caches, e.g. `MessageMentions#channels`.
11022
+ * A {@link Cache} over a raw `@wolfstar/plugin-cache` store (in memory or Redis): the store holds raw API data, and a
11023
+ * structure is built on every read.
10559
11024
  *
10560
- * @param ids The IDs.
10561
- * @param cached The cached structures, by ID.
10562
- * @internal
11025
+ * @remarks
11026
+ * Unlike `CollectionCache`, two reads of the same key return two structures: do not rely on object identity.
10563
11027
  */
10564
- declare function pickCached<Value>(ids: readonly string[], cached: ReadonlyMap<string, Value> | undefined): Map<string, Value>;
11028
+ export declare class EntityStoreCache<Value extends StructureMixin<object>, Raw extends RawAPIType<Value> = RawAPIType<Value>> implements Cache<Value, Raw> {
11029
+ #private;
11030
+ readonly construct: StructureCreator<Value, Raw>;
11031
+ /**
11032
+ * The name of the entity this cache holds.
11033
+ */
11034
+ readonly name: CacheEntityName;
11035
+ /**
11036
+ * The raw store.
11037
+ */
11038
+ readonly store: EntityCache<Raw>;
11039
+ constructor(creator: StructureCreator<Value, Raw>, name: CacheEntityName, options: EntityStoreCacheOptions<Value, Raw>);
11040
+ get synchronous(): boolean;
11041
+ add(data: Partial<Raw>, overwrite?: boolean): Awaitable<Value>;
11042
+ clear(): Awaitable<void>;
11043
+ delete(key: string): Awaitable<boolean>;
11044
+ get(key: string): Awaitable<Value | undefined>;
11045
+ getSize(): Awaitable<number>;
11046
+ has(key: string): Awaitable<boolean>;
11047
+ set(key: string, value: Value): Awaitable<this>;
11048
+ }
11049
+ //#endregion
11050
+ //#region src/util/NullCache.d.ts
10565
11051
  /**
10566
- * Reads the cached structures of some IDs, synchronously when every read is, skipping duplicates and the IDs that
10567
- * are not cached. The {@link Awaitable} counterpart of discord.js's collections filled from its caches.
10568
- *
10569
- * @param ids The IDs.
10570
- * @param get Reads the structure of an ID.
10571
- * @internal
11052
+ * The options of {@link NullCache}.
10572
11053
  */
10573
- declare function whenCachedMap<Value>(ids: Iterable<string>, get: (id: string) => Awaitable<Value | null | undefined>): Awaitable<Map<string, Value>>;
11054
+ export interface NullCacheOptions<Value, Raw> {
11055
+ /**
11056
+ * Builds the structure {@link NullCache.add} answers with, with its relations. May be asynchronous.
11057
+ *
11058
+ * @default The creator.
11059
+ */
11060
+ hydrate?: (data: Raw) => Awaitable<Value>;
11061
+ /**
11062
+ * Whether `hydrate` answers synchronously.
11063
+ *
11064
+ * @default () => true
11065
+ */
11066
+ synchronous?: () => boolean;
11067
+ }
11068
+ /**
11069
+ * The {@link Cache} of an entity that is not cached: always empty, writes are dropped.
11070
+ */
11071
+ export declare class NullCache<Value extends StructureMixin<object>, Raw extends RawAPIType<Value> = RawAPIType<Value>> implements Cache<Value, Raw> {
11072
+ #private;
11073
+ readonly construct: StructureCreator<Value, Raw>;
11074
+ /**
11075
+ * The name of the entity this cache stands for.
11076
+ */
11077
+ readonly name: CacheEntityName;
11078
+ constructor(creator: StructureCreator<Value, Raw>, name: CacheEntityName, options?: NullCacheOptions<Value, Raw>);
11079
+ get synchronous(): boolean;
11080
+ add(data: Partial<Raw>): Awaitable<Value>;
11081
+ clear(): void;
11082
+ delete(): boolean;
11083
+ get(): undefined;
11084
+ getSize(): number;
11085
+ has(): boolean;
11086
+ set(): this;
11087
+ }
10574
11088
  //#endregion
10575
11089
  //#region src/util/container.d.ts
10576
11090
  /**
@@ -11034,5 +11548,5 @@ export interface TransformedResolvedData {
11034
11548
  */
11035
11549
  export declare function transformResolved({ client, guildId }: SupportingResolvedData, { users, members, roles, channels }: ResolvableData): Awaitable<TransformedResolvedData>;
11036
11550
  //#endregion
11037
- export { type AnnouncementChannelResolvable, type ApplicationCommandDataResolvable, type ApplicationCommandPermissionIdResolvable, type ApplicationCommandResolvable, type ApplicationResolvable, type AttachmentPayload, type AttachmentResolvable, type AutoModerationRuleResolvable, CachedManager as BaseManager, type BaseMessageOptions, BitField, type BitFieldResolvable, type BufferResolvable, type CategoryChannelResolvable, type ChannelResolvable, type ColorResolvable, type CommandOptionDataTypeResolvable, type ComponentEmojiResolvable, type DateResolvable, type EmojiResolvable, type EntitlementResolvable, type ForwardOptions, type GatewayClientMessageDefaults, type GuildAuditLogsResolvable, type GuildBanResolvable, type GuildBasedChannel, type GuildChannelResolvable, type GuildInvitableChannel, type GuildInvitableChannelResolvable, type GuildInviteResolvable, type GuildResolvable, type GuildScheduledEventResolvable, type GuildTemplateResolvable, type GuildTextChannelResolvable, type GuildVoiceChannelResolvable, type HexColorString, type InviteResolvable, type JSONEncodable, type MessageActionRowComponentResolvable, type MessageCreateOptions, type MessageEditOptions, type MessageMentionOptions, type MessagePayloadContext, type MessagePayloadOptions, type MessagePayloadResolvable, type MessageReactionResolvable, type MessageResolvable, type MessageTarget, type NonThreadGuildBasedChannel, type OverwriteResolvable, type PermissionOverwriteResolvable, PermissionsBitField, type PollCreateData, type PresenceResolvable, type RawAPIType, type ReplyOptions, type ResolvedMessagePayload, type RoleColorsEditResolvable, type RoleColorsResolvable, type RoleResolvable, type SKUResolvable, type SoundboardSoundResolvable, type StageChannelResolvable, type StageInstanceResolvable, type StickerResolvable, type StructureCreator, type SubscriptionResolvable, type TextBasedChannel, type TextBasedChannelResolvable, type TextChannelResolvable, type ThreadChannel, type ThreadChannelResolvable, type ThreadMemberResolvable, type UserResolvable, type VoiceBasedChannel, type VoiceChannelResolvable, type WebhookMessageCreateOptions, type WebhookMessageEditOptions, type WebhookMessageOptions, type WebhookThreadOptions, type isPromiseLike, type pickCached, type whenAll, type whenCachedMap };
11551
+ export { type AnnouncementChannelResolvable, type ApplicationCommandDataResolvable, type ApplicationCommandPermissionIdResolvable, type ApplicationCommandResolvable, type ApplicationResolvable, type AttachmentPayload, type AttachmentResolvable, type AutoModerationRuleResolvable, type BaseMessageOptions, BitField, type BitFieldResolvable, type BufferResolvable, type Cache, type CacheConstructor, type CacheConstructorOptions, type CacheEntityOptions, type CategoryChannelResolvable, type ChannelResolvable, type ColorResolvable, type CommandOptionDataTypeResolvable, type ComponentEmojiResolvable, type DateResolvable, type EmojiResolvable, type EntitlementResolvable, type ForwardOptions, type GatewayClientMessageDefaults, type GuildAuditLogsResolvable, type GuildBanResolvable, type GuildBasedChannel, type GuildChannelResolvable, type GuildInvitableChannel, type GuildInvitableChannelResolvable, type GuildInviteResolvable, type GuildResolvable, type GuildScheduledEventResolvable, type GuildTemplateResolvable, type GuildTextChannelResolvable, type GuildVoiceChannelResolvable, type HexColorString, type InviteResolvable, type JSONEncodable, type MessageActionRowComponentResolvable, type MessageCreateOptions, type MessageEditOptions, type MessageMentionOptions, type MessagePayloadContext, type MessagePayloadOptions, type MessagePayloadResolvable, type MessageReactionResolvable, type MessageResolvable, type MessageTarget, type NonThreadGuildBasedChannel, type OverwriteResolvable, type PermissionOverwriteResolvable, PermissionsBitField, type PollCreateData, type PresenceResolvable, type RawAPIType, type ReplyOptions, type ResolvedMessagePayload, type RoleColorsEditResolvable, type RoleColorsResolvable, type RoleResolvable, type RoleResolvables, type SKUResolvable, type SoundboardSoundResolvable, type StageChannelResolvable, type StageInstanceResolvable, type StickerResolvable, type StructureCreator, type SubscriptionResolvable, type TextBasedChannel, type TextBasedChannelResolvable, type TextChannelResolvable, type ThreadChannel, type ThreadChannelResolvable, type ThreadMemberResolvable, type UserResolvable, type VoiceBasedChannel, type VoiceChannelResolvable, type WebhookMessageCreateOptions, type WebhookMessageEditOptions, type WebhookMessageOptions, type WebhookThreadOptions, type isPromiseLike, type peekCache, type pickCached, type refreshRelations, type whenAll, type whenCachedMap };
11038
11552
  //# sourceMappingURL=index.d.ts.map