export class Sweepers
A container for all cache sweeping intervals and their associated sweep methods.
Constructors
client: Client<true>options: SweeperOptions)
constructor(Constructs a new instance of the Sweepers
class
readonlyClient client :
Record<SweeperKey, NodeJS.Timeout | null> intervals :
A record of interval timeout that is used to sweep the indicated items, or null if not being swept
SweeperOptions options :
The options the sweepers were instantiated with
static archivedThreadSweepFilterlifetime?: number) : GlobalSweepFilter<SweeperDefinitions['threads'][0], SweeperDefinitions['threads'][1]> (
Creates a sweep filter that sweeps archived threads
destroyvoid () :
Cancels all sweeping intervals
static expiredInviteSweepFilterlifetime?: number) : GlobalSweepFilter<SweeperDefinitions['invites'][0], SweeperDefinitions['invites'][1]> (
Creates a sweep filter that sweeps expired invites
static filterByLifetimeKey
Value
>(options?: LifetimeFilterOptions<Key, Value>) : GlobalSweepFilter<Key, Value> <
Key
Value
Create a sweepFilter function that uses a lifetime to determine sweepability.
static outdatedMessageSweepFilterlifetime?: number) : GlobalSweepFilter<SweeperDefinitions['messages'][0], SweeperDefinitions['messages'][1]> (
Creates a sweep filter that sweeps outdated messages (edits taken into account)
sweepApplicationCommandsfilter: CollectionSweepFilter<SweeperDefinitions['applicationCommands'][0], SweeperDefinitions['applicationCommands'][1]>) : number (
Sweeps all guild and global application commands and removes the ones which are indicated by the filter.
Returns: Amount of commands that were removed from the caches
sweepAutoModerationRulesfilter: CollectionSweepFilter<SweeperDefinitions['autoModerationRules'][0], SweeperDefinitions['autoModerationRules'][1]>) : number (
Sweeps all auto moderation rules and removes the ones which are indicated by the filter.
Returns: Amount of auto moderation rules that were removed from the caches
sweepBansfilter: CollectionSweepFilter<SweeperDefinitions['bans'][0], SweeperDefinitions['bans'][1]>) : number (
Sweeps all guild bans and removes the ones which are indicated by the filter.
Returns: Amount of bans that were removed from the caches
sweepEmojisfilter: CollectionSweepFilter<SweeperDefinitions['emojis'][0], SweeperDefinitions['emojis'][1]>) : number (
Sweeps all guild emojis and removes the ones which are indicated by the filter.
Returns: Amount of emojis that were removed from the caches
sweepEntitlementsfilter: CollectionSweepFilter<SweeperDefinitions['entitlements'][0], SweeperDefinitions['entitlements'][1]>) : number (
Sweeps all client application entitlements and removes the ones which are indicated by the filter.
Returns: Amount of entitlements that were removed from the caches
sweepGuildMembersfilter: CollectionSweepFilter<SweeperDefinitions['guildMembers'][0], SweeperDefinitions['guildMembers'][1]>) : number (
Sweeps all guild members and removes the ones which are indicated by the filter. It is highly recommended to keep the client guild member cached
Returns: Amount of guild members that were removed from the caches
sweepInvitesfilter: CollectionSweepFilter<SweeperDefinitions['invites'][0], SweeperDefinitions['invites'][1]>) : number (
Sweeps all guild invites and removes the ones which are indicated by the filter.
Returns: Amount of invites that were removed from the caches
sweepMessagesfilter: CollectionSweepFilter<SweeperDefinitions['messages'][0], SweeperDefinitions['messages'][1]>) : number (
Sweeps all text-based channels' messages and removes the ones which are indicated by the filter.
// Remove all messages older than 1800 seconds from the messages cache
const amount = sweepers.sweepMessages(
Sweepers.filterByLifetime({
lifetime: 1800,
getComparisonTimestamp: m => m.editedTimestamp ?? m.createdTimestamp,
})(),
);
console.log(`Successfully removed ${amount} messages from the cache.`);
Returns: Amount of messages that were removed from the caches
sweepPresencesfilter: CollectionSweepFilter<SweeperDefinitions['presences'][0], SweeperDefinitions['presences'][1]>) : number (
Sweeps all presences and removes the ones which are indicated by the filter.
Returns: Amount of presences that were removed from the caches
sweepReactionsfilter: CollectionSweepFilter<SweeperDefinitions['reactions'][0], SweeperDefinitions['reactions'][1]>) : number (
Sweeps all message reactions and removes the ones which are indicated by the filter.
Returns: Amount of reactions that were removed from the caches
sweepStageInstancesfilter: CollectionSweepFilter<SweeperDefinitions['stageInstances'][0], SweeperDefinitions['stageInstances'][1]>) : number (
Sweeps all guild stage instances and removes the ones which are indicated by the filter.
Returns: Amount of stage instances that were removed from the caches
sweepStickersfilter: CollectionSweepFilter<SweeperDefinitions['stickers'][0], SweeperDefinitions['stickers'][1]>) : number (
Sweeps all guild stickers and removes the ones which are indicated by the filter.
Returns: Amount of stickers that were removed from the caches
sweepThreadMembersfilter: CollectionSweepFilter<SweeperDefinitions['threadMembers'][0], SweeperDefinitions['threadMembers'][1]>) : number (
Sweeps all thread members and removes the ones which are indicated by the filter. It is highly recommended to keep the client thread member cached
Returns: Amount of thread members that were removed from the caches
sweepThreadsfilter: CollectionSweepFilter<SweeperDefinitions['threads'][0], SweeperDefinitions['threads'][1]>) : number (
Sweeps all threads and removes the ones which are indicated by the filter.
// Remove all threads archived greater than 1 day ago from all the channel caches
const amount = sweepers.sweepThreads(
Sweepers.filterByLifetime({
getComparisonTimestamp: t => t.archivedTimestamp,
excludeFromSweep: t => !t.archived,
})(),
);
console.log(`Successfully removed ${amount} threads from the cache.`);
Returns: filter Amount of threads that were removed from the caches
sweepUsersfilter: CollectionSweepFilter<SweeperDefinitions['users'][0], SweeperDefinitions['users'][1]>) : number (
Sweeps all users and removes the ones which are indicated by the filter.
Returns: Amount of users that were removed from the caches
sweepVoiceStatesfilter: CollectionSweepFilter<SweeperDefinitions['voiceStates'][0], SweeperDefinitions['voiceStates'][1]>) : number (
Sweeps all guild voice states and removes the ones which are indicated by the filter.
Returns: Amount of voice states that were removed from the caches