Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RatelimitBucket

RatelimitBucket, used for ratelimiting the execution of functions.

Hierarchy

  • RatelimitBucket

Index

Constructors

  • new RatelimitBucket(limit?: number, limitReset?: number, defaultReset?: number): RatelimitBucket
  • Create a new Bucket.

    Parameters

    • Optional limit: number

      Number of functions that may be executed during the timeframe set in limitReset.

    • Optional limitReset: number

      Timeframe in milliseconds until the ratelimit resets.

    • Optional defaultReset: number

      If the bucket info does not provide default values, but provides remaining, this is the reset to use after the initial reset.

    Returns RatelimitBucket

Properties

checkQueue: any

Check if there are any functions in the queue that haven't been executed yet.

defaultReset: undefined | number
fnQueue: { error: Error; callback: any; fn: any }[]
limit: number
limitReset: number
remaining: number
resetRemaining: any

Reset the remaining tokens to the base limit.

resetTimeout: null | Timeout
default: typeof RatelimitBucket

Methods

  • dropQueue(): void
  • Clear the current queue of events to be sent.

    Returns void

  • queue<T>(fn: (() => T)): Promise<T>
  • Queue a function to be executed.

    Type Parameters

    • T

    Parameters

    • fn: (() => T)

      Function to be executed.

        • (): T
        • Returns T

    Returns Promise<T>

    Result of the function if any.

Generated using TypeDoc