refactor: merge collections with keeping entries at max (#6242)

This commit is contained in:
1Computer1
2021-07-31 16:03:58 -04:00
committed by GitHub
parent a25e16599a
commit bb5e648f3d
9 changed files with 209 additions and 170 deletions

View File

@@ -3,6 +3,8 @@ import {
ApplicationCommandData,
ApplicationCommandManager,
ApplicationCommandResolvable,
CacheFactory,
Caches,
CategoryChannel,
Client,
ClientApplication,
@@ -22,12 +24,14 @@ import {
GuildResolvable,
Intents,
Interaction,
LimitedCollection,
Message,
MessageActionRow,
MessageAttachment,
MessageButton,
MessageCollector,
MessageEmbed,
MessageManager,
MessageReaction,
NewsChannel,
Options,
@@ -59,9 +63,12 @@ const client: Client = new Client({
// @ts-expect-error
Message: 100,
ThreadManager: {
sweepInterval: require('./SweptCollection').filterByLifetime({
getComparisonTimestamp: (e: any) => e.archiveTimestamp,
excludeFromSweep: (e: any) => !e.archived,
maxSize: 1000,
keepOverLimit: (x: ThreadChannel) => x.id === '123',
sweepInterval: 5000,
sweepFilter: LimitedCollection.filterByLifetime({
getComparisonTimestamp: (x: ThreadChannel) => x.archiveTimestamp ?? 0,
excludeFromSweep: (x: ThreadChannel) => !x.archived,
}),
},
}),