Skip to content

Commit

Permalink
feat(APIRequest): support setting global headers in HTTPOptions (#5586)
Browse files Browse the repository at this point in the history
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
  • Loading branch information
advaith1 and vladfrangu committed May 10, 2021
1 parent 1398431 commit 135abcc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rest/APIRequest.js
Expand Up @@ -33,7 +33,7 @@ class APIRequest {
? this.client.options.http.api
: `${this.client.options.http.api}/v${this.client.options.http.version}`;
const url = API + this.path;
let headers = {};
let headers = { ...this.client.options.http.headers };

if (this.options.auth !== false) headers.Authorization = this.rest.getAuth();
if (this.options.reason) headers['X-Audit-Log-Reason'] = encodeURIComponent(this.options.reason);
Expand Down
1 change: 1 addition & 0 deletions src/util/Constants.js
Expand Up @@ -80,6 +80,7 @@ exports.DefaultOptions = {
* @property {string} [cdn='https://cdn.discordapp.com'] Base url of the CDN
* @property {string} [invite='https://discord.gg'] Base url of invites
* @property {string} [template='https://discord.new'] Base url of templates
* @property {Object} [headers] Additional headers to send for all API requests
*/
http: {
version: 8,
Expand Down
1 change: 1 addition & 0 deletions typings/index.d.ts
Expand Up @@ -2999,6 +2999,7 @@ declare module 'discord.js' {
cdn?: string;
invite?: string;
template?: string;
headers?: Record<string, string>;
}

type ImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
Expand Down

0 comments on commit 135abcc

Please sign in to comment.