Skip to main content

InvalidRequestBucket

@discordeno/rest


Documentation / @discordeno/rest / InvalidRequestBucket

Interface: InvalidRequestBucket

Defined in: rest/src/invalidBucket.ts:122

Properties

activeRequests

activeRequests: number

Defined in: rest/src/invalidBucket.ts:136

The amount of requests that were requested from this bucket.


errorStatuses

errorStatuses: number[]

Defined in: rest/src/invalidBucket.ts:134

The request statuses that count as an invalid request.


handleCompletedRequest()

handleCompletedRequest: (code, sharedScope) => void

Defined in: rest/src/invalidBucket.ts:153

Handler for whenever a request is validated. This should update the requested values or trigger any other necessary stuff.

Parameters

code

number

sharedScope

boolean

Returns

void


interval

interval: number

Defined in: rest/src/invalidBucket.ts:128

The time that discord allows to make the max number of invalid requests. Defaults to 10 minutes


invalidRequests

invalidRequests: number

Defined in: rest/src/invalidBucket.ts:124

current invalid amount


isRequestAllowed()

isRequestAllowed: () => boolean

Defined in: rest/src/invalidBucket.ts:147

Checks if a request is allowed at this time.

Returns

boolean


logger

logger: Pick<{ debug: (...args) => void; error: (...args) => void; fatal: (...args) => void; info: (...args) => void; log: (level, ...args) => void; setDepth: (level) => void; setLevel: (level) => void; warn: (...args) => void; }, "debug" | "info" | "warn" | "error" | "fatal">

Defined in: rest/src/invalidBucket.ts:142

The logger that will be used for the bucket


max

max: number

Defined in: rest/src/invalidBucket.ts:126

max invalid requests allowed until ban. Defaults to 10,000


processing

processing: boolean

Defined in: rest/src/invalidBucket.ts:140

Whether or not the waiting queue is already processing.


processWaiting()

processWaiting: () => Promise<void>

Defined in: rest/src/invalidBucket.ts:151

Begins processing the waiting queue of requests.

Returns

Promise<void>


requestsAllowed()

requestsAllowed: () => number

Defined in: rest/src/invalidBucket.ts:145

Gives the number of requests that are currently allowed.

Returns

number


resetAt

resetAt: undefined | number

Defined in: rest/src/invalidBucket.ts:130

When the timeout for this bucket has started at.


safety

safety: number

Defined in: rest/src/invalidBucket.ts:132

how safe to be from max. Defaults to 1


waiting

waiting: (value) => void[]

Defined in: rest/src/invalidBucket.ts:138

The requests that are currently pending.

Parameters

value

void | PromiseLike<void>

Returns

void


waitUntilRequestAvailable()

waitUntilRequestAvailable: () => Promise<void>

Defined in: rest/src/invalidBucket.ts:149

Waits until a request is available

Returns

Promise<void>