Skip to main content

Class: RateLimit<K>

ratelimits/src.RateLimit

Type parameters

NameType
Kstring

Constructors

constructor

new RateLimit<K>(manager)

Type parameters

NameType
Kstring

Parameters

NameTypeDescription
managerRateLimitManager<K>The manager for this entry.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:22

Properties

expires

expires: number

The timestamp that represents when this entry will reset back to a available state.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:12


manager

Private manager: RateLimitManager<K>

The RateLimitManager this entry is for.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:17


remaining

remaining: number

The remaining amount of times this entry can be dripped before the bucket is empty.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:7

Accessors

expired

get expired(): boolean

Whether this entry is expired or not, allowing the bucket to be reset.

Returns

boolean

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:30


limited

get limited(): boolean

Whether this entry is limited or not.

Returns

boolean

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:37


remainingTime

get remainingTime(): number

The remaining time in milliseconds before resetting.

Returns

number

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:44

Methods

consume

consume(): RateLimit<K>

Consumes RateLimit.remaining by one if it's not limited, calling RateLimit.reset first if RateLimit.expired is true.

Returns

RateLimit<K>

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:51


reset

reset(): RateLimit<K>

Resets the entry back to it's full state.

Returns

RateLimit<K>

Defined in

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


resetRemaining

resetRemaining(): RateLimit<K>

Resets the entry's RateLimit.remaining uses back to full state.

Returns

RateLimit<K>

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:69


resetTime

resetTime(): RateLimit<K>

Resets the entry's RateLimit.expires to the current time plus RateLimitManager.time.

Returns

RateLimit<K>

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:77