CreateRestManagerOptions
Documentation / @discordeno/rest / CreateRestManagerOptions
Interface: CreateRestManagerOptions
Defined in: types.ts:169
Properties
applicationId?
optionalapplicationId?:BigString
Defined in: types.ts:176
For old bots that have a different bot id and application id.
Default
bot id from token
events?
optionalevents?:Partial<RestManagerEvents>
Defined in: types.ts:236
Events for the rest manager
logger?
optionallogger?:Pick<{ },"debug"|"info"|"warn"|"error"|"fatal">
Defined in: types.ts:234
The logger that the rest manager will use
Default
logger // The logger exported by @discordeno/utils
proxy?
optionalproxy?:object
Defined in: types.ts:178
Configuration when using a proxy.
authorization?
optionalauthorization?:string
The authorization header value to attach when sending requests to the proxy.
authorizationHeader?
optionalauthorizationHeader?:string
The authorization header name to use when sending requests to the proxy
Remarks
If the header name is set to authorization, it will override any authorization that is given even if
the requests uses OAuth2 Bearer tokens / Basic tokens
Default
"authorization" // For compatibility purposes
baseUrl
baseUrl:
string
The base url to connect to. If you create a proxy rest, that url would go here.
Default
https://discord.com/api
retryRequests?
optionalretryRequests?:boolean
Whether an attempt that failed without producing a response should be re-sent to the proxy.
Remarks
This covers both an attempt that hit requestTimeout and one whose
connection failed. Neither tells us whether the proxy got the request: the timeout only aborts our side of the
connection while the proxy keeps processing (it may simply be queued behind a rate limit), and a socket that dies
once the request is on the wire may still have delivered it. fetch gives no way to tell those apart from never
having connected at all, so re-sending can execute non-idempotent requests twice (e.g. duplicate channel creates).
Only enable this when re-sending a request to your proxy is safe, for example by attaching an idempotency key to each request that the proxy tracks in a store of your choosing (in memory, redis, ...) so a re-sent request is recognized and executed only once. Discordeno does not provide such a mechanism.
Bounded by RestManager.maxRetryCount and RestManager.maxProxyRetryCount.
Default
false
updateBearerTokenEndpoint?
optionalupdateBearerTokenEndpoint?:string
The endpoint to use in the rest proxy to update the bearer tokens
Remarks
Should not include a / in the start
This value is actually required if you want to use updateTokenQueues
requestTimeout?
optionalrequestTimeout?:number
Defined in: types.ts:258
The maximum time in milliseconds a single request attempt may take before it is aborted.
Remarks
This is a total deadline for each attempt (it also covers reading the response body), not a per-chunk timeout. When talking to Discord directly, a timed-out attempt is retried through the queue up to RestManager.maxRetryCount times before failing. Without it, a connection that stalls after connecting could keep a queue from ever progressing.
When a proxy is configured, a timed-out attempt is NOT retried: the proxy keeps processing the request after
the timeout aborts our side of the connection (it may simply be queued behind a rate limit), so re-sending it
could execute it twice. If re-sending against your proxy is safe, proxy.retryRequests opts back into it.
Because it is a total deadline rather than a per-chunk one, a slow but healthy request (e.g. uploading a large attachment over a slow connection) can legitimately exceed it and be aborted/retried. Raise this value for upload-heavy bots if you see such requests timing out.
Set to 0 to disable it and rely on the runtime's default fetch timeouts.
Default
30000 // 30 seconds
token
token:
string
Defined in: types.ts:171
The bot token which will be used to make requests.
version?
optionalversion?:ApiVersions
Defined in: types.ts:229
The api versions which can be used to make requests.
Default
10