export declare class REST extends AsyncEventEmitter<RestEventsMap>
export declare class REST extends AsyncEventEmitter<RestEventsMap>
Represents the class that manages handlers for endpoints
Extends
AsyncEventEmitter<RestEventsMap>constructor(options?)
Constructs a new instance of the
REST
className | Type | Optional | Description |
---|---|---|---|
options | Partial<RESTOptions> | Yes | None |
agent
:
Dispatcher | null
The Agent for all requests performed by this manager.
Readonly
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
clearHandlerSweeper()
:
void
Stops the request handler sweeping interval
clearHashSweeper()
:
void
Stops the hash sweeping interval
delete(fullRoute, options?)
:
Promise<unknown>
Runs a delete request from the api
Name | Type | Optional | Description |
---|---|---|---|
fullRoute | RouteLike | No | The full route to query |
options | RequestData | Yes | Optional request options |
get(fullRoute, options?)
:
Promise<unknown>
Runs a get request from the api
Name | Type | Optional | Description |
---|---|---|---|
fullRoute | RouteLike | No | The full route to query |
options | RequestData | Yes | Optional request options |
patch(fullRoute, options?)
:
Promise<unknown>
Runs a patch request from the api
Name | Type | Optional | Description |
---|---|---|---|
fullRoute | RouteLike | No | The full route to query |
options | RequestData | Yes | Optional request options |
post(fullRoute, options?)
:
Promise<unknown>
Runs a post request from the api
Name | Type | Optional | Description |
---|---|---|---|
fullRoute | RouteLike | No | The full route to query |
options | RequestData | Yes | Optional request options |
put(fullRoute, options?)
:
Promise<unknown>
Runs a put request from the api
Name | Type | Optional | Description |
---|---|---|---|
fullRoute | RouteLike | No | The full route to query |
options | RequestData | Yes | Optional request options |
Queues a request to be sent
Name | Type | Optional | Description |
---|---|---|---|
request | InternalRequest | No | All the information needed to make a request |
request(options)
:
Promise<unknown>
Runs a request from the api
Name | Type | Optional | Description |
---|---|---|---|
options | InternalRequest | No | Request options |
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 |