Class: RateLimitManager<K>
@sapphire/ratelimits.RateLimitManager
Type parameters
Name | Type |
---|---|
K | string |
Hierarchy
Constructors
constructor
• new RateLimitManager<K
>(time
, limit?
)
Type parameters
Name | Type |
---|---|
K | string |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
time | number | undefined | The amount of milliseconds for the ratelimits from this manager to expire. |
limit | number | 1 | The 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:23
Properties
[toStringTag]
• Readonly
[toStringTag]: string
Inherited from
Map.[toStringTag]
Defined in
node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:137
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:12
size
• Readonly
size: number
Inherited from
Map.size
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:46
sweepInterval
• Private
sweepInterval: null
| Timer
The interval to sweep expired ratelimits.
Defined in
projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:17
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:7
[species]
▪ Static
Readonly
[species]: MapConstructor
Inherited from
Map.[species]
Defined in
node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:319
sweepIntervalDuration
▪ Static
sweepIntervalDuration: number
= 30_000
The delay in milliseconds for sweepInterval.
Defined in
projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:75
Methods
[iterator]
▸ [iterator](): IterableIterator
<[K
, RateLimit
<K
>]>
Returns an iterable of entries in the map.
Returns
IterableIterator
<[K
, RateLimit
<K
>]>
Inherited from
Map.[iterator]
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:119
acquire
▸ acquire(id
): RateLimit
<K
>
Gets a RateLimit from this manager or creates it if it does not exist.
Parameters
Name | Type | Description |
---|---|---|
id | K | The id for the RateLimit |
Returns
RateLimit
<K
>
Defined in
projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:34
clear
▸ clear(): void
Returns
void
Inherited from
Map.clear
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:21
create
▸ create(id
): RateLimit
<K
>
Creates a RateLimit for this manager.
Parameters
Name | Type | Description |
---|---|---|
id | K | The id the RateLimit belongs to |
Returns
RateLimit
<K
>
Defined in
projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:42
delete
▸ delete(key
): boolean
Parameters
Name | Type |
---|---|
key | K |
Returns
boolean
true if an element in the Map existed and has been removed, or false if the element does not exist.
Inherited from
Map.delete
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:25
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:124
forEach
▸ forEach(callbackfn
, thisArg?
): void
Executes a provided function once per each key/value pair in the Map, in insertion order.
Parameters
Name | Type |
---|---|
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:29
get
▸ get(key
): undefined
| RateLimit
<K
>
Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
Parameters
Name | Type |
---|---|
key | K |
Returns
undefined
| RateLimit
<K
>
Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
Inherited from
Map.get
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:34
has
▸ has(key
): boolean
Parameters
Name | Type |
---|---|
key | K |
Returns
boolean
boolean indicating whether an element with the specified key exists or not.
Inherited from
Map.has
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:38
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:129
set
▸ set(id
, value
): RateLimitManager
<K
>
Wraps Collection's set method to set interval to sweep inactive RateLimits.
Parameters
Name | Type | Description |
---|---|---|
id | K | The id the RateLimit belongs to |
value | RateLimit <K > | The RateLimit to set |
Returns
Overrides
Map.set
Defined in
projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:53
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:61
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:134