From 5820b3538c603043d85bd56ae5c281dc1280e34d Mon Sep 17 00:00:00 2001 From: Dev-CasperTheGhost <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Thu, 3 Jun 2021 16:19:18 +0200 Subject: [PATCH 1/8] fix(Typings): add missing typings for `HttpError` -> `requestData` --- typings/index.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/typings/index.d.ts b/typings/index.d.ts index 7f781319c8e3..be6a05e33234 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -710,6 +710,7 @@ declare module 'discord.js' { public method: string; public path: string; public httpStatus: number; + public requestData: HTTPErrorData } export class DMChannel extends TextBasedChannel(Channel, ['bulkDelete']) { @@ -1050,6 +1051,7 @@ declare module 'discord.js' { public method: string; public name: string; public path: string; + public requestData: HTTPErrorData } export class Integration extends Base { @@ -3083,6 +3085,16 @@ declare module 'discord.js' { cache?: boolean; } + interface HTTPErrorData { + json: any; + files: HTTPAttachmentData[] + } + + interface HTTPAttachmentData { + name: string; + file: Buffer + } + interface HTTPOptions { api?: string; version?: number; From 9ffaba9d4ff0b6e81b5999bf1c9db9a2ff6fb995 Mon Sep 17 00:00:00 2001 From: Dev-CasperTheGhost <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Thu, 3 Jun 2021 16:22:05 +0200 Subject: [PATCH 2/8] fix(Typings): alphabetical order --- typings/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index be6a05e33234..aae0b95b1c4f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3085,16 +3085,16 @@ declare module 'discord.js' { cache?: boolean; } - interface HTTPErrorData { - json: any; - files: HTTPAttachmentData[] - } - interface HTTPAttachmentData { name: string; file: Buffer } + interface HTTPErrorData { + json: any; + files: HTTPAttachmentData[] + } + interface HTTPOptions { api?: string; version?: number; From d50a495c3778e603ef2e066f6e9404c497dfa85a Mon Sep 17 00:00:00 2001 From: Dev-CasperTheGhost <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Thu, 3 Jun 2021 16:24:17 +0200 Subject: [PATCH 3/8] fix(Typings): semicolons --- typings/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index aae0b95b1c4f..2fe88b948d23 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -710,7 +710,7 @@ declare module 'discord.js' { public method: string; public path: string; public httpStatus: number; - public requestData: HTTPErrorData + public requestData: HTTPErrorData; } export class DMChannel extends TextBasedChannel(Channel, ['bulkDelete']) { @@ -1051,7 +1051,7 @@ declare module 'discord.js' { public method: string; public name: string; public path: string; - public requestData: HTTPErrorData + public requestData: HTTPErrorData; } export class Integration extends Base { @@ -3087,12 +3087,12 @@ declare module 'discord.js' { interface HTTPAttachmentData { name: string; - file: Buffer + file: Buffer; } interface HTTPErrorData { json: any; - files: HTTPAttachmentData[] + files: HTTPAttachmentData[]; } interface HTTPOptions { From 07658bc0e7253eb76b5ee8aa87df52d4dadb8480 Mon Sep 17 00:00:00 2001 From: Dev-CasperTheGhost <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Thu, 3 Jun 2021 16:51:44 +0200 Subject: [PATCH 4/8] fix(Typings): use `unknown` instead of `any` --- typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 2fe88b948d23..c9283f7b5d20 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3091,7 +3091,7 @@ declare module 'discord.js' { } interface HTTPErrorData { - json: any; + json: unknown; files: HTTPAttachmentData[]; } From 362087f03cd2f679ca7559446c0424876cb51048 Mon Sep 17 00:00:00 2001 From: Dev-CasperTheGhost <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Thu, 3 Jun 2021 17:00:46 +0200 Subject: [PATCH 5/8] fix(Typings): update constructors --- typings/index.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index c9283f7b5d20..6568ba755c53 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -703,7 +703,7 @@ declare module 'discord.js' { } export class DiscordAPIError extends Error { - constructor(path: string, error: unknown, method: string, httpStatus: number); + constructor(error: unknown, status: number, request: HTTPRequest); private static flattenErrors(obj: unknown, key: string): string[]; public code: number; @@ -1046,7 +1046,7 @@ declare module 'discord.js' { } export class HTTPError extends Error { - constructor(message: string, name: string, code: number, method: string, path: string); + constructor(message: string, name: string, code: number, request: HTTPRequest); public code: number; public method: string; public name: string; @@ -3095,6 +3095,10 @@ declare module 'discord.js' { files: HTTPAttachmentData[]; } + interface HTTPRequest { + options: HTTPErrorData; + } + interface HTTPOptions { api?: string; version?: number; From 4b7d80250bca0535c54dd57e0f53a1b3fb23c74e Mon Sep 17 00:00:00 2001 From: Casper <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Thu, 3 Jun 2021 15:50:12 +0000 Subject: [PATCH 6/8] Apply suggestions from code review Co-authored-by: SpaceEEC --- typings/index.d.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 6568ba755c53..d99d908070c8 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -703,7 +703,7 @@ declare module 'discord.js' { } export class DiscordAPIError extends Error { - constructor(error: unknown, status: number, request: HTTPRequest); + constructor(error: unknown, status: number, request: unknown); private static flattenErrors(obj: unknown, key: string): string[]; public code: number; @@ -1046,7 +1046,7 @@ declare module 'discord.js' { } export class HTTPError extends Error { - constructor(message: string, name: string, code: number, request: HTTPRequest); + constructor(message: string, name: string, code: number, request: unknown); public code: number; public method: string; public name: string; @@ -3086,8 +3086,9 @@ declare module 'discord.js' { } interface HTTPAttachmentData { + attachment: string; name: string; - file: Buffer; + file: Buffer | Stream; } interface HTTPErrorData { @@ -3095,10 +3096,6 @@ declare module 'discord.js' { files: HTTPAttachmentData[]; } - interface HTTPRequest { - options: HTTPErrorData; - } - interface HTTPOptions { api?: string; version?: number; From 6683640c0165bc39ae8fd78c2abc1775fea2e78c Mon Sep 17 00:00:00 2001 From: Dev-CasperTheGhost <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Thu, 3 Jun 2021 17:53:48 +0200 Subject: [PATCH 7/8] fix(Typings): update JSDoc from code review suggestion --- src/rest/HTTPError.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rest/HTTPError.js b/src/rest/HTTPError.js index 8613cd947529..8623bbb3108f 100644 --- a/src/rest/HTTPError.js +++ b/src/rest/HTTPError.js @@ -42,8 +42,9 @@ class HTTPError extends Error { /** * The attachment data that is sent to Discord * @typedef {Object} HTTPAttachmentData + * @property {string} attachment The attachment * @property {string} name The file name - * @property {Buffer} file The file buffer + * @property {Buffer|Stream} file The file buffer */ /** From 3eea16ba95b476c3eb11f7bdf6c8bbb0e6f1dbb9 Mon Sep 17 00:00:00 2001 From: Dev-CasperTheGhost <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Thu, 3 Jun 2021 18:04:55 +0200 Subject: [PATCH 8/8] fix(Typings): Apply suggestions from code review --- src/rest/HTTPError.js | 2 +- typings/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rest/HTTPError.js b/src/rest/HTTPError.js index 8623bbb3108f..cb96a2beb1f6 100644 --- a/src/rest/HTTPError.js +++ b/src/rest/HTTPError.js @@ -42,7 +42,7 @@ class HTTPError extends Error { /** * The attachment data that is sent to Discord * @typedef {Object} HTTPAttachmentData - * @property {string} attachment The attachment + * @property {string|Buffer|Stream} attachment The source of this attachment data * @property {string} name The file name * @property {Buffer|Stream} file The file buffer */ diff --git a/typings/index.d.ts b/typings/index.d.ts index d99d908070c8..9124fe276837 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3086,7 +3086,7 @@ declare module 'discord.js' { } interface HTTPAttachmentData { - attachment: string; + attachment: string | Buffer | Stream; name: string; file: Buffer | Stream; }