Preview environment

class REST

export declare class REST extends AsyncEventEmitter<RestEvents>

Represents the class that manages handlers for endpoints

Constructors

constructor(
options?: Partial<RESTOptions>
)

Constructs a new instance of the REST class

agent : Dispatcher | null

The Agent for all requests performed by this manager.

readonly
cdn : CDN

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
options : RESTOptions

clearHandlerSweeper() : void

Stops the request handler sweeping interval

clearHashSweeper() : void

Stops the hash sweeping interval

delete(
fullRoute: RouteLike
options?: RequestData
) : Promise<unknown>

Runs a delete request from the api

get(
fullRoute: RouteLike
options?: RequestData
) : Promise<unknown>

Runs a get request from the api

patch(
fullRoute: RouteLike
options?: RequestData
) : Promise<unknown>

Runs a patch request from the api

post(
fullRoute: RouteLike
options?: RequestData
) : Promise<unknown>

Runs a post request from the api

put(
fullRoute: RouteLike
options?: RequestData
) : Promise<unknown>

Runs a put request from the api

queueRequest() : Promise<ResponseLike>

Queues a request to be sent

Returns: The response from the api request

request() : Promise<unknown>

Runs a request from the api

setAgent(
agent: Dispatcher
) : this

Sets the default agent to use for requests performed by this manager

setToken(
token: string
) : this

Sets the authorization token that should be used for requests