Skip to main content

Class: RateLimit<K>

@sapphire/ratelimits.RateLimit

Type parameters

Name
K

Constructors

constructor

โ€ข new RateLimit<K>(manager)

Type parameters

Name
K

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