@wolfstar/plugin-gateway 0.9.0-next-20261002163719 → 0.9.0
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.
- package/README.md +61 -1
- package/dist/esm/index.d.ts +306 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +324 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -61,7 +61,9 @@ var EventGatewayListener = class extends Listener {
|
|
|
61
61
|
const GatewayErrorMessages = {
|
|
62
62
|
ClientSessionStoreConflict: "sessionStore replaces gateway.retrieveSessionInfo and gateway.updateSessionInfo, pass one or the other",
|
|
63
63
|
ClientCacheConflict: "cacheConstructor and cacheOptions cannot be combined with cache or makeCache, pass one or the other",
|
|
64
|
+
ClientSweepersConflict: "sweepers cannot be combined with cache or makeCache, whose stores hold raw data a sweep cannot filter: use their policies' ttl instead",
|
|
64
65
|
ClientNotConstructed: "No GatewayClient has been constructed yet",
|
|
66
|
+
SweeperIntervalTooLong: (entity, interval) => `The sweeper of ${entity} has an interval of ${interval}s, which a timer cannot wait for: the maximum is 2147483s`,
|
|
65
67
|
DispatchHandlerConflict: (event) => `Dispatch event "${event}" is registered in both DispatchHandlers and MultiDispatchHandlers`,
|
|
66
68
|
DispatchTimeout: (type, shardId, partition, timeout) => `Processing ${type} on shard ${shardId} (${partition ?? "barrier"}) took longer than ${timeout}ms`,
|
|
67
69
|
SessionStoreFailed: (operation, shardId) => `Cannot ${operation === "get" ? "read" : "write"} the session of shard ${shardId} in the session store`,
|
|
@@ -14556,6 +14558,7 @@ let GatewayEvents = /* @__PURE__ */ function(GatewayEvents) {
|
|
|
14556
14558
|
GatewayEvents["ShardClose"] = "shardClose";
|
|
14557
14559
|
GatewayEvents["ShardError"] = "shardError";
|
|
14558
14560
|
GatewayEvents["CacheError"] = "cacheError";
|
|
14561
|
+
GatewayEvents["CacheSweep"] = "cacheSweep";
|
|
14559
14562
|
GatewayEvents["GuildCreate"] = "guildCreate";
|
|
14560
14563
|
GatewayEvents["GuildUpdate"] = "guildUpdate";
|
|
14561
14564
|
GatewayEvents["GuildDelete"] = "guildDelete";
|
|
@@ -15638,6 +15641,7 @@ var CollectionCache = class extends Collection {
|
|
|
15638
15641
|
#keyOf;
|
|
15639
15642
|
#refresh;
|
|
15640
15643
|
#maxSize;
|
|
15644
|
+
#keepOverLimit;
|
|
15641
15645
|
constructor(creator, name, options = {}) {
|
|
15642
15646
|
super();
|
|
15643
15647
|
this.construct = creator;
|
|
@@ -15645,6 +15649,7 @@ var CollectionCache = class extends Collection {
|
|
|
15645
15649
|
this.#keyOf = options.keyOf ?? ((data) => data.id);
|
|
15646
15650
|
this.#refresh = options.refresh;
|
|
15647
15651
|
this.#maxSize = options.maxSize ?? Infinity;
|
|
15652
|
+
this.#keepOverLimit = options.keepOverLimit;
|
|
15648
15653
|
}
|
|
15649
15654
|
add(data, overwrite = false) {
|
|
15650
15655
|
const key = this.#keyOf(data);
|
|
@@ -15663,9 +15668,10 @@ var CollectionCache = class extends Collection {
|
|
|
15663
15668
|
}
|
|
15664
15669
|
set(key, value) {
|
|
15665
15670
|
if (this.#maxSize <= 0) return this;
|
|
15666
|
-
if (this.size >= this.#maxSize && !super.has(key)) {
|
|
15667
|
-
|
|
15668
|
-
|
|
15671
|
+
if (this.size >= this.#maxSize && !super.has(key)) for (const [oldKey, oldValue] of this) {
|
|
15672
|
+
if (this.#keepOverLimit?.(oldValue, oldKey, this)) continue;
|
|
15673
|
+
super.delete(oldKey);
|
|
15674
|
+
break;
|
|
15669
15675
|
}
|
|
15670
15676
|
return super.set(key, value);
|
|
15671
15677
|
}
|
|
@@ -15842,6 +15848,260 @@ var NullCache = class {
|
|
|
15842
15848
|
}
|
|
15843
15849
|
};
|
|
15844
15850
|
|
|
15851
|
+
//#endregion
|
|
15852
|
+
//#region src/util/Sweepers.ts
|
|
15853
|
+
/**
|
|
15854
|
+
* Every {@link SweepableEntityName}.
|
|
15855
|
+
*/
|
|
15856
|
+
const SweepableEntityNames = [
|
|
15857
|
+
"autoModerationRules",
|
|
15858
|
+
"bans",
|
|
15859
|
+
"emojis",
|
|
15860
|
+
"invites",
|
|
15861
|
+
"members",
|
|
15862
|
+
"messages",
|
|
15863
|
+
"presences",
|
|
15864
|
+
"stageInstances",
|
|
15865
|
+
"stickers",
|
|
15866
|
+
"threadMembers",
|
|
15867
|
+
"threads",
|
|
15868
|
+
"users",
|
|
15869
|
+
"voiceStates"
|
|
15870
|
+
];
|
|
15871
|
+
const MaxTimerDelay = 2 ** 31 - 1;
|
|
15872
|
+
const lifetimeFilters = {
|
|
15873
|
+
invites: { getComparisonTimestamp: (invite) => invite.expiresTimestamp },
|
|
15874
|
+
messages: { getComparisonTimestamp: (message) => message.editedTimestamp ?? message.createdTimestamp },
|
|
15875
|
+
threads: {
|
|
15876
|
+
getComparisonTimestamp: (thread) => thread.archiveTimestamp,
|
|
15877
|
+
excludeFromSweep: (thread) => !thread.archived
|
|
15878
|
+
}
|
|
15879
|
+
};
|
|
15880
|
+
function lifetimeFilterOf(entity, lifetime) {
|
|
15881
|
+
return Sweepers.filterByLifetime({
|
|
15882
|
+
...lifetimeFilters[entity],
|
|
15883
|
+
lifetime
|
|
15884
|
+
});
|
|
15885
|
+
}
|
|
15886
|
+
/**
|
|
15887
|
+
* Evicts entries from the caches of instances, on a schedule or on demand, like discord.js's `Sweepers`.
|
|
15888
|
+
*
|
|
15889
|
+
* @remarks
|
|
15890
|
+
* It works with the caches the client builds from {@link GatewayClientOptions.cacheConstructor}, the default
|
|
15891
|
+
* `CollectionCache` included: they are `Map`s. The stores of `@wolfstar/plugin-cache` hold raw data, and expire it
|
|
15892
|
+
* with the `ttl` of their policies instead, so sweeping them throws.
|
|
15893
|
+
*
|
|
15894
|
+
* A sweep only evicts entries from the cache: it emits no event but `cacheSweep`, and the structures the application
|
|
15895
|
+
* keeps stay valid.
|
|
15896
|
+
*
|
|
15897
|
+
* @example
|
|
15898
|
+
* ```typescript
|
|
15899
|
+
* const client = new GatewayClient({
|
|
15900
|
+
* intents,
|
|
15901
|
+
* sweepers: {
|
|
15902
|
+
* // Every hour, forget the messages not touched for half an hour.
|
|
15903
|
+
* messages: { interval: 3_600, lifetime: 1_800 },
|
|
15904
|
+
* // Every hour, forget the bots.
|
|
15905
|
+
* users: { interval: 3_600, filter: () => (user) => user.bot },
|
|
15906
|
+
* },
|
|
15907
|
+
* });
|
|
15908
|
+
*
|
|
15909
|
+
* // On demand.
|
|
15910
|
+
* client.sweepers.sweepMessages(600);
|
|
15911
|
+
* ```
|
|
15912
|
+
*/
|
|
15913
|
+
var Sweepers = class {
|
|
15914
|
+
/**
|
|
15915
|
+
* The options the sweepers were scheduled from.
|
|
15916
|
+
*/
|
|
15917
|
+
options;
|
|
15918
|
+
#client;
|
|
15919
|
+
#timers = /* @__PURE__ */ new Map();
|
|
15920
|
+
constructor(client, options = {}) {
|
|
15921
|
+
this.#client = client;
|
|
15922
|
+
this.options = options;
|
|
15923
|
+
try {
|
|
15924
|
+
for (const entity of SweepableEntityNames) this.#schedule(entity);
|
|
15925
|
+
} catch (error) {
|
|
15926
|
+
this.destroy();
|
|
15927
|
+
throw error;
|
|
15928
|
+
}
|
|
15929
|
+
}
|
|
15930
|
+
/**
|
|
15931
|
+
* Evicts the entries of an entity's cache the filter answers `true` for.
|
|
15932
|
+
*
|
|
15933
|
+
* @param entity The name of the entity.
|
|
15934
|
+
* @param filter Builds the filter of the sweep.
|
|
15935
|
+
* @returns The amount of entries evicted, `0` when the filter skips the sweep or the entity is not cached.
|
|
15936
|
+
*/
|
|
15937
|
+
sweep(entity, filter) {
|
|
15938
|
+
const cache = this.#client.cacheOf(entity);
|
|
15939
|
+
if (cache === void 0 || cache instanceof NullCache) return 0;
|
|
15940
|
+
if (!(cache instanceof Map)) throw new GatewayTypeError("CacheNotIterable", entity);
|
|
15941
|
+
const predicate = filter();
|
|
15942
|
+
if (predicate === null) return 0;
|
|
15943
|
+
const start = Date.now();
|
|
15944
|
+
const before = cache.size;
|
|
15945
|
+
for (const [key, value] of cache) if (predicate(value, key, cache)) cache.delete(key);
|
|
15946
|
+
const swept = before - cache.size;
|
|
15947
|
+
this.#client.logger.debug(`[Sweepers] Swept ${swept} ${entity} in ${Date.now() - start}ms`);
|
|
15948
|
+
this.#client.emit("cacheSweep", entity, swept);
|
|
15949
|
+
return swept;
|
|
15950
|
+
}
|
|
15951
|
+
/**
|
|
15952
|
+
* Evicts the auto moderation rules the filter answers `true` for.
|
|
15953
|
+
*/
|
|
15954
|
+
sweepAutoModerationRules(filter) {
|
|
15955
|
+
return this.sweep("autoModerationRules", filter);
|
|
15956
|
+
}
|
|
15957
|
+
/**
|
|
15958
|
+
* Evicts the bans the filter answers `true` for.
|
|
15959
|
+
*/
|
|
15960
|
+
sweepBans(filter) {
|
|
15961
|
+
return this.sweep("bans", filter);
|
|
15962
|
+
}
|
|
15963
|
+
/**
|
|
15964
|
+
* Evicts the emojis the filter answers `true` for.
|
|
15965
|
+
*/
|
|
15966
|
+
sweepEmojis(filter) {
|
|
15967
|
+
return this.sweep("emojis", filter);
|
|
15968
|
+
}
|
|
15969
|
+
/**
|
|
15970
|
+
* Evicts the invites that expired more than `lifetime` seconds ago.
|
|
15971
|
+
*
|
|
15972
|
+
* @param lifetime The seconds an invite lives past its expiration.
|
|
15973
|
+
*/
|
|
15974
|
+
sweepInvites(lifetime = 14400) {
|
|
15975
|
+
return this.sweep("invites", lifetimeFilterOf("invites", lifetime));
|
|
15976
|
+
}
|
|
15977
|
+
/**
|
|
15978
|
+
* Evicts the members the filter answers `true` for.
|
|
15979
|
+
*/
|
|
15980
|
+
sweepMembers(filter) {
|
|
15981
|
+
return this.sweep("members", filter);
|
|
15982
|
+
}
|
|
15983
|
+
/**
|
|
15984
|
+
* Evicts the messages created or last edited more than `lifetime` seconds ago.
|
|
15985
|
+
*
|
|
15986
|
+
* @param lifetime The seconds a message lives.
|
|
15987
|
+
*/
|
|
15988
|
+
sweepMessages(lifetime = 3600) {
|
|
15989
|
+
return this.sweep("messages", lifetimeFilterOf("messages", lifetime));
|
|
15990
|
+
}
|
|
15991
|
+
/**
|
|
15992
|
+
* Evicts the presences the filter answers `true` for.
|
|
15993
|
+
*/
|
|
15994
|
+
sweepPresences(filter) {
|
|
15995
|
+
return this.sweep("presences", filter);
|
|
15996
|
+
}
|
|
15997
|
+
/**
|
|
15998
|
+
* Evicts the stage instances the filter answers `true` for.
|
|
15999
|
+
*/
|
|
16000
|
+
sweepStageInstances(filter) {
|
|
16001
|
+
return this.sweep("stageInstances", filter);
|
|
16002
|
+
}
|
|
16003
|
+
/**
|
|
16004
|
+
* Evicts the stickers the filter answers `true` for.
|
|
16005
|
+
*/
|
|
16006
|
+
sweepStickers(filter) {
|
|
16007
|
+
return this.sweep("stickers", filter);
|
|
16008
|
+
}
|
|
16009
|
+
/**
|
|
16010
|
+
* Evicts the thread members the filter answers `true` for.
|
|
16011
|
+
*/
|
|
16012
|
+
sweepThreadMembers(filter) {
|
|
16013
|
+
return this.sweep("threadMembers", filter);
|
|
16014
|
+
}
|
|
16015
|
+
/**
|
|
16016
|
+
* Evicts the threads archived more than `lifetime` seconds ago, see {@link Sweepers.outdatedThreadSweepFilter}.
|
|
16017
|
+
*
|
|
16018
|
+
* @param lifetime The seconds a thread lives past its archival.
|
|
16019
|
+
*/
|
|
16020
|
+
sweepThreads(lifetime = 14400) {
|
|
16021
|
+
return this.sweep("threads", lifetimeFilterOf("threads", lifetime));
|
|
16022
|
+
}
|
|
16023
|
+
/**
|
|
16024
|
+
* Evicts the users the filter answers `true` for.
|
|
16025
|
+
*/
|
|
16026
|
+
sweepUsers(filter) {
|
|
16027
|
+
return this.sweep("users", filter);
|
|
16028
|
+
}
|
|
16029
|
+
/**
|
|
16030
|
+
* Evicts the voice states the filter answers `true` for.
|
|
16031
|
+
*/
|
|
16032
|
+
sweepVoiceStates(filter) {
|
|
16033
|
+
return this.sweep("voiceStates", filter);
|
|
16034
|
+
}
|
|
16035
|
+
/**
|
|
16036
|
+
* Stops the scheduled sweeps. On-demand sweeps keep working.
|
|
16037
|
+
*/
|
|
16038
|
+
destroy() {
|
|
16039
|
+
for (const timer of this.#timers.values()) clearInterval(timer);
|
|
16040
|
+
this.#timers.clear();
|
|
16041
|
+
}
|
|
16042
|
+
/**
|
|
16043
|
+
* Builds a filter factory evicting the entries older than a lifetime, for {@link Sweepers.sweep} and the `filter`
|
|
16044
|
+
* of a sweeper.
|
|
16045
|
+
*
|
|
16046
|
+
* @param options The lifetime, and what it is counted from.
|
|
16047
|
+
*/
|
|
16048
|
+
static filterByLifetime(options = {}) {
|
|
16049
|
+
const { lifetime = 14400, getComparisonTimestamp = (value) => value.createdTimestamp, excludeFromSweep = () => false } = options;
|
|
16050
|
+
if (typeof lifetime !== "number") throw new GatewayTypeError("InvalidType", "lifetime", "number");
|
|
16051
|
+
return () => {
|
|
16052
|
+
if (lifetime <= 0) return null;
|
|
16053
|
+
const lifetimeMs = lifetime * 1e3;
|
|
16054
|
+
const now = Date.now();
|
|
16055
|
+
return (value, key, collection) => {
|
|
16056
|
+
if (excludeFromSweep(value, key, collection)) return false;
|
|
16057
|
+
const timestamp = getComparisonTimestamp(value, key, collection);
|
|
16058
|
+
if (typeof timestamp !== "number" || !timestamp) return false;
|
|
16059
|
+
return now - timestamp > lifetimeMs;
|
|
16060
|
+
};
|
|
16061
|
+
};
|
|
16062
|
+
}
|
|
16063
|
+
/**
|
|
16064
|
+
* Builds a filter factory evicting the archived threads that have been so for longer than a lifetime. Active
|
|
16065
|
+
* threads are never evicted.
|
|
16066
|
+
*
|
|
16067
|
+
* @param lifetime The seconds a thread lives past its archival.
|
|
16068
|
+
* @default 14400
|
|
16069
|
+
*/
|
|
16070
|
+
static outdatedThreadSweepFilter(lifetime = 14400) {
|
|
16071
|
+
return lifetimeFilterOf("threads", lifetime);
|
|
16072
|
+
}
|
|
16073
|
+
#schedule(entity) {
|
|
16074
|
+
const options = this.options[entity];
|
|
16075
|
+
if (options === void 0) return;
|
|
16076
|
+
const path = `sweepers.${entity}`;
|
|
16077
|
+
const { interval } = options;
|
|
16078
|
+
if (typeof interval !== "number" || Number.isNaN(interval)) throw new GatewayTypeError("InvalidType", `${path}.interval`, "number");
|
|
16079
|
+
let filter;
|
|
16080
|
+
if (options.lifetime !== void 0) {
|
|
16081
|
+
if (typeof options.lifetime !== "number") throw new GatewayTypeError("InvalidType", `${path}.lifetime`, "number");
|
|
16082
|
+
if (!(entity in lifetimeFilters)) throw new GatewayTypeError("InvalidType", `${path}.filter`, "function");
|
|
16083
|
+
filter = lifetimeFilterOf(entity, options.lifetime);
|
|
16084
|
+
} else if (typeof options.filter === "function") filter = options.filter;
|
|
16085
|
+
else throw new GatewayTypeError("InvalidType", `${path}.filter`, "function");
|
|
16086
|
+
if (interval <= 0 || interval === Infinity) return;
|
|
16087
|
+
const delay = interval * 1e3;
|
|
16088
|
+
if (delay > MaxTimerDelay) throw new GatewayRangeError("SweeperIntervalTooLong", entity, interval);
|
|
16089
|
+
const timer = setInterval(() => {
|
|
16090
|
+
try {
|
|
16091
|
+
this.sweep(entity, filter);
|
|
16092
|
+
} catch (error) {
|
|
16093
|
+
this.#client.emit("cacheError", error, {
|
|
16094
|
+
entity,
|
|
16095
|
+
key: null,
|
|
16096
|
+
operation: "sweep"
|
|
16097
|
+
});
|
|
16098
|
+
}
|
|
16099
|
+
}, delay);
|
|
16100
|
+
timer.unref();
|
|
16101
|
+
this.#timers.set(entity, timer);
|
|
16102
|
+
}
|
|
16103
|
+
};
|
|
16104
|
+
|
|
15845
16105
|
//#endregion
|
|
15846
16106
|
//#region src/util/StructureStoreAdapter.ts
|
|
15847
16107
|
function toRaw(value) {
|
|
@@ -16011,6 +16271,11 @@ var GatewayClient = class extends Client {
|
|
|
16011
16271
|
voiceStates;
|
|
16012
16272
|
presences;
|
|
16013
16273
|
/**
|
|
16274
|
+
* Evicts entries from the caches of instances, on the schedule of {@link GatewayClientOptions.sweepers} and on
|
|
16275
|
+
* demand, like discord.js's `Client#sweepers`.
|
|
16276
|
+
*/
|
|
16277
|
+
sweepers;
|
|
16278
|
+
/**
|
|
16014
16279
|
* What happens to a dispatch whose cache read or write fails, see {@link GatewayClientOptions.cacheFailure}.
|
|
16015
16280
|
*/
|
|
16016
16281
|
cacheFailure;
|
|
@@ -16056,6 +16321,7 @@ var GatewayClient = class extends Client {
|
|
|
16056
16321
|
this.rest = container.rest;
|
|
16057
16322
|
const storeBacked = Boolean(options.cache || options.makeCache);
|
|
16058
16323
|
if ((options.cacheConstructor || options.cacheOptions) && storeBacked) throw new GatewayTypeError("ClientCacheConflict");
|
|
16324
|
+
if (options.sweepers && storeBacked) throw new GatewayTypeError("ClientSweepersConflict");
|
|
16059
16325
|
this.#cacheOptions = options.cacheOptions ?? {};
|
|
16060
16326
|
const stores = resolveCache(options);
|
|
16061
16327
|
this.#stores = stores;
|
|
@@ -16083,6 +16349,7 @@ var GatewayClient = class extends Client {
|
|
|
16083
16349
|
this.voiceStates = new VoiceStateManager(this);
|
|
16084
16350
|
this.presences = new PresenceManager(this);
|
|
16085
16351
|
this.cache = this.#cacheConstructor ? this.#createStructureStores(options.policies) : stores;
|
|
16352
|
+
this.sweepers = new Sweepers(this, this.#cacheConstructor ? options.sweepers : void 0);
|
|
16086
16353
|
this.gateway = new WebSocketManager({
|
|
16087
16354
|
...options.gateway,
|
|
16088
16355
|
...this.sessionCallbacks(options),
|
|
@@ -16132,6 +16399,7 @@ var GatewayClient = class extends Client {
|
|
|
16132
16399
|
* @param options Whether to keep the sessions resumable.
|
|
16133
16400
|
*/
|
|
16134
16401
|
destroy(options = {}) {
|
|
16402
|
+
this.sweepers.destroy();
|
|
16135
16403
|
this.#destroying ??= this.disconnect(options.resumable ?? false).finally(() => {
|
|
16136
16404
|
this.#destroying = null;
|
|
16137
16405
|
});
|
|
@@ -16185,6 +16453,15 @@ var GatewayClient = class extends Client {
|
|
|
16185
16453
|
return cache;
|
|
16186
16454
|
}
|
|
16187
16455
|
/**
|
|
16456
|
+
* Gets the cache of an entity if it was built already, without building it.
|
|
16457
|
+
*
|
|
16458
|
+
* @param name The name of the entity.
|
|
16459
|
+
* @internal
|
|
16460
|
+
*/
|
|
16461
|
+
cacheOf(name) {
|
|
16462
|
+
return this.#caches.get(name);
|
|
16463
|
+
}
|
|
16464
|
+
/**
|
|
16188
16465
|
* Runs a raw store operation, reporting its failure through `cacheError`, see
|
|
16189
16466
|
* {@link GatewayClientOptions.cacheErrors}. Synchronous when the operation is.
|
|
16190
16467
|
*
|
|
@@ -16657,5 +16934,48 @@ function RegisterAsGatewayListener(event, options = {}) {
|
|
|
16657
16934
|
}
|
|
16658
16935
|
|
|
16659
16936
|
//#endregion
|
|
16660
|
-
|
|
16937
|
+
//#region src/util/limits.ts
|
|
16938
|
+
/**
|
|
16939
|
+
* Builds the {@link GatewayClientOptions.cacheOptions} bounding the caches of some entities, like discord.js's
|
|
16940
|
+
* `Options.cacheWithLimits`. A number is the `maxSize` of the entity, an object is its whole options.
|
|
16941
|
+
*
|
|
16942
|
+
* @example
|
|
16943
|
+
* ```typescript
|
|
16944
|
+
* const client = new GatewayClient({
|
|
16945
|
+
* intents,
|
|
16946
|
+
* // Keep the 200 most recent messages, no presences, and up to 1000 members, plus any member in a voice channel.
|
|
16947
|
+
* cacheOptions: cacheWithLimits({
|
|
16948
|
+
* messages: 200,
|
|
16949
|
+
* presences: 0,
|
|
16950
|
+
* members: { maxSize: 1_000, keepOverLimit: (member) => member.voice?.channelId != null },
|
|
16951
|
+
* }),
|
|
16952
|
+
* });
|
|
16953
|
+
* ```
|
|
16954
|
+
*
|
|
16955
|
+
* @param limits The `maxSize` or the options of each entity.
|
|
16956
|
+
*/
|
|
16957
|
+
function cacheWithLimits(limits) {
|
|
16958
|
+
return Object.fromEntries(Object.entries(limits).map(([name, limit]) => [name, typeof limit === "number" ? { maxSize: limit } : limit]));
|
|
16959
|
+
}
|
|
16960
|
+
/**
|
|
16961
|
+
* Ready-made {@link GatewayClientOptions.sweepers}, for a bot that only needs recent messages and threads: every hour,
|
|
16962
|
+
* messages untouched for 30 minutes are evicted, and so are threads archived for more than four hours.
|
|
16963
|
+
*
|
|
16964
|
+
* @remarks
|
|
16965
|
+
* Unlike discord.js's `Options.DefaultSweeperSettings`, which is empty, it sweeps. Spread it to override an entity:
|
|
16966
|
+
* `sweepers: { ...DefaultSweeperSettings, users: { interval: 3_600, filter: () => (user) => user.bot } }`.
|
|
16967
|
+
*/
|
|
16968
|
+
const DefaultSweeperSettings = Object.freeze({
|
|
16969
|
+
messages: {
|
|
16970
|
+
interval: 3600,
|
|
16971
|
+
lifetime: 1800
|
|
16972
|
+
},
|
|
16973
|
+
threads: {
|
|
16974
|
+
interval: 3600,
|
|
16975
|
+
lifetime: 14400
|
|
16976
|
+
}
|
|
16977
|
+
});
|
|
16978
|
+
|
|
16979
|
+
//#endregion
|
|
16980
|
+
export { Action, ActionRow, ActionsManager, Activity, ActivityFlagsBitField, AnnouncementChannel, AnnouncementThreadChannel, AnonymousGuild, ApplicationFlagsBitField, AppliedTagsMixin, Attachment, AttachmentFlagsBitField, AutoModerationActionExecution, AutoModerationRule, AutoModerationRuleManager, BaseChannel, BaseChannelMixin, BaseInvite, BaseManager, BitField, CachedManager, CategoryChannel, Channel, ChannelFlagsBitField, ChannelManager, ChannelMessageManager, ChannelOwnerMixin, ChannelParentMixin, ChannelPermissionMixin, ChannelSelectMenuComponent, ChannelSlowmodeMixin, ChannelThreadManager, ChannelThreadsMixin, ChannelTopicMixin, ChannelWebhooksMixin, CheckboxComponent, CheckboxGroupComponent, ClientUser, CollectionCache, Colors, Component, ComponentMixin, ContainerComponent, DMChannel, DMChannelMixin, DataManager, DefaultSweeperSettings, DispatchAction, DispatchHandlers, DispatchQueue, DispatchStateCodecs, DispatchTimeoutError, Embed, Emoji, EntityStoreCache, EventGatewayListener, FileComponent, FileUploadComponent, ForumChannel, GatewayClient, GatewayError, GatewayErrorCodes, GatewayErrorMessages, GatewayEvents, GatewayRangeError, GatewaySessionStoreError, GatewayTypeError, GroupDMChannel, GroupDMInvite, GroupDMMixin, Guild, GuildAuditLogsEntry, GuildBan, GuildBanManager, GuildChannelFields, GuildChannelManager, GuildChannelMixin, GuildEmoji, GuildEmojiManager, GuildEmojiRoleManager, GuildIntegrationManager, GuildInvite, GuildInviteManager, GuildManager, GuildMember, GuildMemberFlagsBitField, GuildMemberManager, GuildMemberRoleManager, GuildMembersRateLimitError, GuildMembersTimeoutError, GuildOnboarding, GuildOnboardingPrompt, GuildOnboardingPromptOption, GuildPreview, GuildScheduledEvent, GuildScheduledEventManager, GuildSoundboardSoundManager, GuildStickerManager, GuildTemplate, GuildTemplateManager, GuildTemplatesPattern, Integration, IntentsBitField, InteractiveButtonComponent, InviteGuild, InvitesPattern, LabelComponent, LinkButtonComponent, MediaChannel, MediaGalleryComponent, MediaGalleryItem, MentionableSelectMenuComponent, Message, MessageFlagsBitField, MessageManager, MessageMentions, MessagePayload, MessageReaction, Mixin, MultiDispatchAction, MultiDispatchHandlers, NullCache, NumberFlagsBitField, Partials, PermissionOverwriteManager, PermissionOverwrites, PermissionsBitField, Poll, PollAnswer, PremiumButtonComponent, Presence, PresenceManager, PrivateThreadChannel, PublicThreadChannel, RadioGroupComponent, ReactionEmoji, ReactionManager, ReactionUserManager, RegisterAsGatewayListener, RichPresenceAssets, Role, RoleFlagsBitField, RoleManager, RoleSelectMenuComponent, SectionComponent, SeparatorComponent, SoundboardSound, StageChannel, StageInstance, StageInstanceManager, Sticker, StickerPack, StringSelectMenuComponent, Structure, StructureMixin, SweepableEntityNames, Sweepers, SystemChannelFlagsBitField, TextChannel, TextChannelMixin, TextDisplayComponent, TextInputComponent, ThreadChannelMemberManager, ThreadChannelMixin, ThreadManager, ThreadMember, ThreadMemberManager, ThreadOnlyChannelMixin, ThumbnailComponent, Typing, UnfurledMediaItem, User, UserFlagsBitField, UserManager, UserSelectMenuComponent, VoiceChannel, VoiceChannelMixin, VoiceState, VoiceStateManager, Webhook, WebhookManager, WebhookMixin, WelcomeScreen, Widget, WidgetMember, basename, bindClient, cacheWithLimits, cleanCodeBlockContent, cleanContent, compareRolePositions, computeCachedPermissionsIn, computeCachedTargetPermissions, computeChannelPermissions, computeGuildPermissions, computePermissionsIn, computePositions, computeTargetPermissions, createChannel, createComponent, createInvite, discordSort, dispatchPartition, findComponentByCustomId, findName, flatten, getGatewayClient, getSortableGroupTypes, initStructure, isDeepEqual, isThreadChannelType, kClient, kClone, kData, kPatch, kPatchRelations, kRelations, lazyRelation, makeError, makePlainError, moveElementInArray, parseEmoji, parseWebhookURL, requireGuild, requireMe, resolveBase64, resolveCode, resolveColor, resolveFile, resolveGuildTemplateCode, resolveId, resolveImage, resolveImageOption, resolveInviteCode, resolveOverwriteOptions, resolvePartialEmoji, resolveSKUId, snakeCase, snowflakeTimestamp, toAPIOverwrite, toChannelBody, toSnakeCase, transformAPIAuditLogChange, transformAPIAutoModerationAction, transformAPIAutoModerationRuleTriggerMetadata, transformAPIAvatarDecorationData, transformAPIChannelMention, transformAPIEmbedAsset, transformAPIEmbedAuthor, transformAPIEmbedFooter, transformAPIGuildDefaultReaction, transformAPIGuildForumTag, transformAPIGuildScheduledEventEntityMetadata, transformAPIGuildScheduledEventRecurrenceRule, transformAPIIncidentsData, transformAPIMessageActivity, transformAPIMessageCall, transformAPIMessageInteractionMetadata, transformAPIMessageReference, transformAPIRoleSubscriptionData, transformAPIRoleTags, transformAPIUserPrimaryGuild, transformAutoModerationAction, transformAutoModerationRuleTriggerMetadata, transformCollectibles, transformGuildDefaultReaction, transformGuildForumTag, transformGuildScheduledEventRecurrenceRule, transformResolved, verifyString };
|
|
16661
16981
|
//# sourceMappingURL=index.js.map
|