diff --git a/src/rest/APIRequest.js b/src/rest/APIRequest.js index 63eda14..8d3c3f3 100644 --- a/src/rest/APIRequest.js +++ b/src/rest/APIRequest.js @@ -33,7 +33,7 @@ class APIRequest { this.path = `${path}${queryString && `?${queryString}`}`; } - make(captchaKey = undefined) { + make(captchaKey = undefined, captchaRqtoken = undefined) { agent ??= typeof this.client.options.proxy === 'string' && this.client.options.proxy.length > 0 ? new proxy(this.client.options.proxy) @@ -53,7 +53,7 @@ class APIRequest { 'Accept-Language': 'en-US,en;q=0.9', 'Cache-Control': 'no-cache', Pragma: 'no-cache', - 'Sec-Ch-Ua': `"Google Chrome";v="${chromeVersion}", "Chromium";v="${chromeVersion}", "Not=A?Brand";v="24"`, + 'Sec-Ch-Ua': `"Google Chrome";v="${chromeVersion}", "Chromium";v="${chromeVersion}", "Not=A?Brand";v="8"`, 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Windows"', 'Sec-Fetch-Dest': 'empty', @@ -109,6 +109,7 @@ class APIRequest { if (headers['Content-Type'] === 'application/json' && captchaKey && typeof captchaKey == 'string') { body = JSON.parse(body || '{}'); body.captcha_key = captchaKey; + if (captchaRqtoken) body.captcha_rqtoken = captchaRqtoken; body = JSON.stringify(body); } diff --git a/src/rest/RequestHandler.js b/src/rest/RequestHandler.js index ad328ea..1f3152b 100644 --- a/src/rest/RequestHandler.js +++ b/src/rest/RequestHandler.js @@ -2,6 +2,7 @@ const { setTimeout } = require('node:timers'); const { setTimeout: sleep } = require('node:timers/promises'); +const { inspect } = require('util'); const { AsyncQueue } = require('@sapphire/async-queue'); const DiscordAPIError = require('./DiscordAPIError'); const HTTPError = require('./HTTPError'); @@ -112,7 +113,7 @@ class RequestHandler { } } - async execute(request, captchaKey) { + async execute(request, captchaKey, captchaToken) { /* * After calculations have been done, pre-emptively stop further requests * Potentially loop until this task can run if e.g. the global rate limit is hit twice @@ -203,7 +204,7 @@ class RequestHandler { // Perform the request let res; try { - res = await request.make(captchaKey); + res = await request.make(captchaKey, captchaToken); } catch (error) { // Retry the specified number of times for request abortions if (request.retries === this.manager.client.options.retryLimit) { @@ -365,7 +366,7 @@ class RequestHandler { Method : ${request.method} Path : ${request.path} Route : ${request.route} - Sitekey : ${data.captcha_sitekey}`, + Info : ${inspect(data, { depth: null })}`, ); const captcha = await this.manager.captchaService.solve(data.captcha_sitekey); this.manager.client.emit( @@ -374,10 +375,10 @@ class RequestHandler { Method : ${request.method} Path : ${request.path} Route : ${request.route} - Key : ${captcha}`, + Key : ${captcha.slice(0, 50)}...`, ); request.retries++; - return this.execute(request, captcha); + return this.execute(request, captcha, data.captcha_rqtoken); } } catch (err) { throw new HTTPError(err.message, err.constructor.name, err.status, request);