Interface RequestManagerOptions

interface RequestManagerOptions {
    agent: Dispatcher;
    api: string;
    authPrefix: "Bot" | "Bearer";
    cdn: string;
    globalRequestsPerSecond: number;
    handlerSweepInterval: number;
    hashLifetime: number;
    hashSweepInterval: number;
    headers: Record<string, string>;
    invalidRequestWarningInterval: number;
    mediaProxy: string;
    offset: number | GetRateLimitOffsetFunction;
    rejectOnRateLimit: string[] | RateLimitQueueFilter;
    retries: number;
    store?: KeyvStoreAdapter;
    storeDeserialize?: ((text, reviver?) => any);
    storeSerialize?: {
        (value, replacer?, space?): string;
        (value, replacer?, space?): string;
    };
    timeout: number;
    userAgentAppendix: string;
    version: string;
    makeRequest(url, init): Promise<ResponseLike>;
}

Hierarchy

  • RESTOptions
    • RequestManagerOptions

Properties

agent: Dispatcher

The agent to set globally

api: string

The base api path, without version

Default Value

'https://discord.com/api'

authPrefix: "Bot" | "Bearer"

The authorization prefix to use for requests, useful if you want to use bearer tokens

Default Value

'Bot'

cdn: string

The cdn path

Default Value

'https://cdn.discordapp.com'

globalRequestsPerSecond: number

How many requests to allow sending per second (Infinity for unlimited, 50 for the standard global limit used by Discord)

Default Value

50

handlerSweepInterval: number

The amount of time in milliseconds that passes between each hash sweep. (defaults to 1h)

Default Value

3_600_000

hashLifetime: number

The maximum amount of time a hash can exist in milliseconds without being hit with a request (defaults to 24h)

Default Value

86_400_000

hashSweepInterval: number

The amount of time in milliseconds that passes between each hash sweep. (defaults to 4h)

Default Value

14_400_000

headers: Record<string, string>

Additional headers to send for all API requests

Default Value

{}

invalidRequestWarningInterval: number

The number of invalid REST requests (those that return 401, 403, or 429) in a 10 minute window between emitted warnings (0 for no warnings). That is, if set to 500, warnings will be emitted at invalid request number 500, 1000, 1500, and so on.

Default Value

0

mediaProxy: string

The media proxy path

Default Value

'https://media.discordapp.net'

offset: number | GetRateLimitOffsetFunction

The extra offset to add to rate limits in milliseconds

Default Value

50

rejectOnRateLimit: string[] | RateLimitQueueFilter

Determines how rate limiting and pre-emptive throttling should be handled. When an array of strings, each element is treated as a prefix for the request route (e.g. /channels to match any route starting with /channels such as /channels/:id/messages) for which to throw RateLimitErrors. All other request routes will be queued normally

Default Value

null

retries: number

The number of retries for errors with the 500 code, or errors that timeout

Default Value

3

store?: KeyvStoreAdapter
storeDeserialize?: ((text, reviver?) => any)

Type declaration

    • (text, reviver?): any
    • Converts a JavaScript Object Notation (JSON) string into an object.

      Parameters

      • text: string

        A valid JSON string.

      • Optional reviver: ((this, key, value) => any)

        A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.

          • (this, key, value): any
          • Parameters

            • this: any
            • key: string
            • value: any

            Returns any

      Returns any

storeSerialize?: {
    (value, replacer?, space?): string;
    (value, replacer?, space?): string;
}

Type declaration

    • (value, replacer?, space?): string
    • Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

      Parameters

      • value: any

        A JavaScript value, usually an object or array, to be converted.

      • Optional replacer: ((this, key, value) => any)

        A function that transforms the results.

          • (this, key, value): any
          • Parameters

            • this: any
            • key: string
            • value: any

            Returns any

      • Optional space: string | number

        Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.

      Returns string

    • (value, replacer?, space?): string
    • Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

      Parameters

      • value: any

        A JavaScript value, usually an object or array, to be converted.

      • Optional replacer: (string | number)[]

        An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.

      • Optional space: string | number

        Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.

      Returns string

timeout: number

The time to wait in milliseconds before a request is aborted

Default Value

15_000

userAgentAppendix: string

Extra information to add to the user agent

Default Value

DefaultUserAgentAppendix
version: string

The version of the API to use

Default Value

'10'

Methods

  • The method called to perform the actual HTTP request given a url and web fetch options For example, to use global fetch, simply provide makeRequest: fetch

    Parameters

    • url: string
    • init: RequestInit

    Returns Promise<ResponseLike>

Generated using TypeDoc