mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(APIRequest): support setting global headers in HTTPOptions (#5586)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
This commit is contained in:
@@ -33,7 +33,7 @@ class APIRequest {
|
|||||||
? this.client.options.http.api
|
? this.client.options.http.api
|
||||||
: `${this.client.options.http.api}/v${this.client.options.http.version}`;
|
: `${this.client.options.http.api}/v${this.client.options.http.version}`;
|
||||||
const url = API + this.path;
|
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.auth !== false) headers.Authorization = this.rest.getAuth();
|
||||||
if (this.options.reason) headers['X-Audit-Log-Reason'] = encodeURIComponent(this.options.reason);
|
if (this.options.reason) headers['X-Audit-Log-Reason'] = encodeURIComponent(this.options.reason);
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ exports.DefaultOptions = {
|
|||||||
* @property {string} [cdn='https://cdn.discordapp.com'] Base url of the CDN
|
* @property {string} [cdn='https://cdn.discordapp.com'] Base url of the CDN
|
||||||
* @property {string} [invite='https://discord.gg'] Base url of invites
|
* @property {string} [invite='https://discord.gg'] Base url of invites
|
||||||
* @property {string} [template='https://discord.new'] Base url of templates
|
* @property {string} [template='https://discord.new'] Base url of templates
|
||||||
|
* @property {Object} [headers] Additional headers to send for all API requests
|
||||||
*/
|
*/
|
||||||
http: {
|
http: {
|
||||||
version: 8,
|
version: 8,
|
||||||
|
|||||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@@ -2999,6 +2999,7 @@ declare module 'discord.js' {
|
|||||||
cdn?: string;
|
cdn?: string;
|
||||||
invite?: string;
|
invite?: string;
|
||||||
template?: string;
|
template?: string;
|
||||||
|
headers?: Record<string, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
type ImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
|
type ImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
|
||||||
|
|||||||
Reference in New Issue
Block a user