Rest
REST represents an interface to manipulate the Discord REST API. When making any sort of REST request, this class is used so that we accurately track the rate limits and add the token to each request.
Summary
Properties
Rest.token :: SecretRest.logger :: LoggerRest.routeRatelimits :: { [string]: { remaining: number, limit: number, resetAfter: number } }Rest.routeBuckets :: { [string]: string? }Rest.globalRequestCount :: numberRest.globalRatelimit :: numberRest.isBlocked :: booleanRest.resourcesBlocked :: { [string]: boolean? }Rest.intents :: numberRest.version :: numberProperties
Section titled “Properties”logger
Section titled “logger”routeRatelimits
Section titled “routeRatelimits”routeBuckets
Section titled “routeBuckets” Rest.routeBuckets :: {
{ [string]: string? } }
{ [string]: string? } }
globalRequestCount
Section titled “globalRequestCount”globalRatelimit
Section titled “globalRatelimit”isBlocked
Section titled “isBlocked”resourcesBlocked
Section titled “resourcesBlocked” Rest.resourcesBlocked :: {
{ [string]: boolean? } }
{ [string]: boolean? } }
intents
Section titled “intents”version
Section titled “version”Methods
Section titled “Methods”yieldUntil
Section titled “yieldUntil”Rest : yieldUntil ( callback , message ) -> ()
Quality of life method to yield, warn after a specific duration, and resume once a condition has been met
Parameters
| callback: () -> boolean | |
| message: string |
implementBucketRatelimitsFor
Section titled “implementBucketRatelimitsFor”Rest : implementBucketRatelimitsFor ( request ) -> ()
Adds per-route bucket rate limit handling for each request.
Parameters
| request: Request |
implementGlobalRatelimitsFor
Section titled “implementGlobalRatelimitsFor”Rest : implementGlobalRatelimitsFor ( request ) -> ()
Adds global ratelimiting to application
Parameters
| request: Request |
implementErrorHandlerFor
Section titled “implementErrorHandlerFor”Rest : implementErrorHandlerFor ( request ) -> ()
Responsible for handling errors that occur when a request has been sent to discord
Parameters
| request: Request |
newRequest
Section titled “newRequest”Rest : newRequest ( ) -> Request
Will create a new Request
Returns
| Request |
Functions
Section titled “Functions”implementAttachmentHandlerFor
Section titled “implementAttachmentHandlerFor”Rest . implementAttachmentHandlerFor ( _ , request ) -> ()
Responsible for handling errors that occur when a request has been sent to discord
Rest . new ( settings ) -> REST
Will create a new REST object