RequestManager
declare class RequestManager extends EventEmitter
declare class RequestManager extends EventEmitter
Represents the class that manages handlers for endpoints
Extends
EventEmitterconstructor(options)
Constructs a new instance of the
RequestManager
className | Type | Optional | Description |
---|---|---|---|
options | Partial<RESTOptions> | No | None |
agent
:
Dispatcher | null
The Agent for all requests performed by this manager.
globalDelay
:
Promise<void> | null
The promise used to wait out the global rate limit
globalRemaining
:
number
The number of requests remaining in the global bucket
globalReset
:
number
The timestamp at which the global bucket resets
Readonly
handlers
:
Collection<string, IHandler>
Request handlers created from the bucket hash and the major parameters
Readonly
hashes
:
Collection<string, HashData>
API bucket hashes that are cached from provided routes
Readonly
emit
:
(<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]) => boolean) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]) => boolean)
Inherited from RequestManager
off
:
(<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this)
Inherited from RequestManager
on
:
(<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this)
Inherited from RequestManager
once
:
(<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this)
Inherited from RequestManager
removeAllListeners
:
(<K extends keyof RestEvents>(event?: K) => this) & (<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>) => this)
Inherited from RequestManager
clearHandlerSweeper()
:
void
Stops the request handler sweeping interval
clearHashSweeper()
:
void
Stops the hash sweeping interval
queueRequest(request)
:
Promise<Dispatcher.ResponseData>
Queues a request to be sent
Name | Type | Optional | Description |
---|---|---|---|
request | InternalRequest | No | All the information needed to make a request |
setAgent(agent)
:
this
Sets the default agent to use for requests performed by this manager
Name | Type | Optional | Description |
---|---|---|---|
agent | Dispatcher | No | The agent to use |
setToken(token)
:
this
Sets the authorization token that should be used for requests
Name | Type | Optional | Description |
---|---|---|---|
token | string | No | The authorization token to use |