Skip to main content

Class: RateLimitManager<K>

@sapphire/ratelimits.RateLimitManager

Type parameters

NameType
Kstring

Hierarchy

Constructors

constructor

โ€ข new RateLimitManager<K>(time, limit?)

Type parameters

NameType
Kstring

Parameters

NameTypeDefault valueDescription
timenumberundefinedThe amount of milliseconds for the ratelimits from this manager to expire.
limitnumber1The amount of times a RateLimit can drip before it's limited.

Overrides

Map<K, RateLimit<K\>\>.constructor

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:24

Properties

[toStringTag]

โ€ข Readonly [toStringTag]: string

Inherited from

Map.__@toStringTag@554268

Defined in

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:135


limit

โ€ข Readonly limit: number

The amount of times a RateLimit can drip before it's limited.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:13


size

โ€ข Readonly size: number

Inherited from

Map.size

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:28


sweepInterval

โ€ข Private sweepInterval: null | Timer

The interval to sweep expired ratelimits.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:18


time

โ€ข Readonly time: number

The amount of milliseconds for the ratelimits from this manager to expire.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:8


[species]

โ–ช Static Readonly [species]: MapConstructor

Inherited from

Map.__@species@554837

Defined in

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:317


sweepIntervalDuration

โ–ช Static sweepIntervalDuration: number = 30_000

The delay in milliseconds for RateLimitManager.sweepInterval.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:76

Methods

[iterator]

โ–ธ [iterator](): IterableIterator<[K, RateLimit<K>]>

Returns an iterable of entries in the map.

Returns

IterableIterator<[K, RateLimit<K>]>

Inherited from

Map.__@iterator@554325

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:121


acquire

โ–ธ acquire(id): RateLimit<K>

Gets a RateLimit from this manager or creates it if it does not exist.

Parameters

NameTypeDescription
idKThe id for the RateLimit

Returns

RateLimit<K>

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:35


clear

โ–ธ clear(): void

Returns

void

Inherited from

Map.clear

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:22


create

โ–ธ create(id): RateLimit<K>

Creates a RateLimit for this manager.

Parameters

NameTypeDescription
idKThe id the RateLimit belongs to

Returns

RateLimit<K>

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:43


delete

โ–ธ delete(key): boolean

Parameters

NameType
keyK

Returns

boolean

Inherited from

Map.delete

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:23


entries

โ–ธ entries(): IterableIterator<[K, RateLimit<K>]>

Returns an iterable of key, value pairs for every entry in the map.

Returns

IterableIterator<[K, RateLimit<K>]>

Inherited from

Map.entries

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:126


forEach

โ–ธ forEach(callbackfn, thisArg?): void

Parameters

NameType
callbackfn(value: RateLimit<K>, key: K, map: Map<K, RateLimit<K>>) => void
thisArg?any

Returns

void

Inherited from

Map.forEach

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:24


get

โ–ธ get(key): undefined | RateLimit<K>

Parameters

NameType
keyK

Returns

undefined | RateLimit<K>

Inherited from

Map.get

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:25


has

โ–ธ has(key): boolean

Parameters

NameType
keyK

Returns

boolean

Inherited from

Map.has

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:26


keys

โ–ธ keys(): IterableIterator<K>

Returns an iterable of keys in the map

Returns

IterableIterator<K>

Inherited from

Map.keys

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:131


set

โ–ธ set(id, value): RateLimitManager<K>

Wraps Collection's set method to set interval to sweep inactive RateLimits.

Parameters

NameTypeDescription
idKThe id the RateLimit belongs to
valueRateLimit<K>The RateLimit to set

Returns

RateLimitManager<K>

Overrides

Map.set

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:54


sweep

โ–ธ sweep(): void

Wraps Collection's sweep method to clear the interval when this manager is empty.

Returns

void

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:62


values

โ–ธ values(): IterableIterator<RateLimit<K>>

Returns an iterable of values in the map

Returns

IterableIterator<RateLimit<K>>

Inherited from

Map.values

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:136