From 9af5d8954a8f123cb6847739da454b3b62159f8a Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Thu, 16 Jun 2022 18:20:18 +0700 Subject: [PATCH] feat(DiscordAPIErrror): Support Captcha solve service --- src/rest/DiscordAPIError.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/rest/DiscordAPIError.js b/src/rest/DiscordAPIError.js index 3137b7b..f262ac0 100644 --- a/src/rest/DiscordAPIError.js +++ b/src/rest/DiscordAPIError.js @@ -25,7 +25,7 @@ class DiscordAPIError extends Error { /** * HTTP error code returned by Discord - * @type {number} + * @type {number | string} */ this.code = error.code; @@ -35,6 +35,19 @@ class DiscordAPIError extends Error { */ this.httpStatus = status; + /** + * @typedef {Object} Captcha + * @property {Array} captcha_key ['captcha-required'] + * @property {string} captcha_sitekey Captcha code ??? + * @property {string} captcha_service hcaptcha + */ + + /** + * Captcha response data if the request requires a captcha + * @type {Captcha | null} + */ + this.captcha = error?.captcha_service ? error : null; + /** * The data associated with the request that caused this error * @type {HTTPErrorData}