RateLimitManager

Handles creation and retrieval of RateLimit objects for the given interval and a given set of descriptors. Similar to RateLimiter but not designed around Messages and Users. This simplifies the process of assigning ratelimits for any arbitrary process/task

Methods

.call(limit: string, descriptors: string) → boolean

Return the result of the RateLimit#call for the given descriptors. See RateLimitManager#get for details on fetching RateLimits via descriptors

Parameters:
Name Type Attributes Description
limit
string

Ratelimit string matching the regex \d+\/\d+[s|m|h|d]
Example: 1/10m to create ratelimits of 1 per 10 minutes

descriptors
string
<repeatable>

RateLimit target descriptors

Source:
Returns:
boolean

.get(limit: string, descriptors: string)RateLimit

Get a RateLimit object for the given target descriptors. This can be any arbitrary set of strings representing whatever you want. A good example would be a RateLimit for a User within a Guild with 5 uses per minute:

<RateLimitManager>.get('5/1m', guild.id, user.id);

Or if you wanted to limit something in a DM for the specific User to 10 uses per 5 minutes:

<RateLimitManager>.get('10/5m', user.id, 'DM');

The possibilities are endless.

Note: The limit string counts as part of the descriptor. As such

<RateLimitManager>.get('1/5m');

is a valid descriptor, but keep in mind that every time you retrieve it, it will be the same RateLimit instance, so if you need unique RateLimits for the same limit/duration, you must create a unique descriptor

Parameters:
Name Type Attributes Description
limit
string

Ratelimit string matching the regex \d+\/\d+[s|m|h|d]
Example: 1/10m to create ratelimits of 1 per 10 minutes

descriptors
string
<repeatable>

RateLimit target descriptors

Source:
Returns:
RateLimit