diff --git a/index.d.ts b/index.d.ts index 419f660e..a898256d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -479,6 +479,7 @@ declare namespace Dysnomia { disableLatencyCompensation?: boolean; domain?: string; port?: string; + headers?: Record; https?: boolean; latencyThreshold?: number; ratelimiterOffset?: number; diff --git a/lib/Client.js b/lib/Client.js index b1ca1545..17345fc0 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -125,6 +125,7 @@ class Client extends EventEmitter { * @arg {Boolean} [options.rest.https=true] Whether to make requests to the Discord API over HTTPS (true) or HTTP (false) * @arg {Number} [options.rest.latencyThreshold=30000] The average request latency at which Dysnomia will start emitting latency errors * @arg {Number} [options.rest.port] The port to use for API requests. Defaults to 443 (HTTPS) or 80 (HTTP) + * @arg {Object} [options.rest.headers] Headers to be appended in REST requests * @arg {Number} [options.rest.ratelimiterOffset=0] A number of milliseconds to offset the ratelimit timing calculations by * @arg {Number} [options.rest.requestTimeout=15000] A number of milliseconds before REST requests are considered timed out * @arg {Boolean} [options.restMode=false] Whether to enable getting objects over REST. Even with this option enabled, it is recommended that you check the cache first before using REST diff --git a/lib/rest/RequestHandler.js b/lib/rest/RequestHandler.js index 2a60c799..7d17c4c8 100644 --- a/lib/rest/RequestHandler.js +++ b/lib/rest/RequestHandler.js @@ -83,6 +83,9 @@ class RequestHandler { let finalURL = url; try { + if(this.options.headers) { + Object.assign(headers, this.options.headers); + } if(auth) { headers.Authorization = this.#client._token; }