Interface SelectingRequestOptions<T>

Request options for requests which may encounter a MultipleChoicesError

interface SelectingRequestOptions {
    allowCache?: boolean;
    apiKey?: string;
    cacheFor?: number;
    ignoreVersion?: boolean;
    multipleChoicesSelector?: ((v, i, a) => boolean | Promise<boolean>);
    priority?: boolean;
    retries?: number;
    timeout?: number;
}

Type Parameters

  • T

Hierarchy

Implemented by

Properties

allowCache?: boolean

Whether to allow this request to use the cache or ongoing requests if available

Requests using cache or other requests do not count towards the ratelimit and return a lot faster.
apiKey?: string

The API key to use in this request

The key has to be registered in the config.
If this is not given, the registered key with the most free requests will be selected.
cacheFor?: number

The amount of time the request should be cached for, overwrites the defaults specified in the config

ignoreVersion?: boolean

Whether to ignore version errors

You can use this to resolve temporary conflicts while the library awaits being updated. Otherwise it should stay enabled.

Default

false
multipleChoicesSelector?: ((v, i, a) => boolean | Promise<boolean>)

Type declaration

    • (v, i, a): boolean | Promise<boolean>
    • A function that will be executed with each of the choices as a parameter. It may return a Promise of a boolean. In that case, the selector will be executed for all values simultaneously. And the passing element with the lowest index will be selected. If the selector returns false for all choices, the error is thrown regardless

      Parameters

      • v: T

        The current choice

      • i: number

        The index of the current choice

      • a: T[]

        The array of all choices

      Returns boolean | Promise<boolean>

      True, if the given choice should be selected

priority?: boolean

Whether this request should be put to the front of the queue, executing before any non-priority requests are handled

Default

false
retries?: number

The amount of times to retry the request on error

timeout?: number

The amount of milliseconds a until the request should be rejected

Be aware that each retry has it's own timeout, meaning 30,000 ms of timeout may lead to a 90,000 ms wait until a request is rejected on 2 retries.

Generated using TypeDoc