fix: captcha data
This commit is contained in:
parent
18e7f8171f
commit
c33767095c
@ -70,6 +70,7 @@
|
||||
"safe-base64": "^2.0.1-0",
|
||||
"string_decoder": "^1.3.0",
|
||||
"string-similarity": "^4.0.4",
|
||||
"tough-cookie": "^4.1.2",
|
||||
"ws": "^8.13.0"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -6,8 +6,10 @@ const { setTimeout } = require('node:timers');
|
||||
const makeFetchCookie = require('fetch-cookie');
|
||||
const FormData = require('form-data');
|
||||
const fetchOriginal = require('node-fetch');
|
||||
const { CookieJar } = require('tough-cookie');
|
||||
|
||||
const fetch = makeFetchCookie(fetchOriginal);
|
||||
const cookieJar = new CookieJar();
|
||||
const fetch = makeFetchCookie(fetchOriginal, cookieJar);
|
||||
|
||||
let agent = null;
|
||||
|
||||
@ -85,6 +87,10 @@ class APIRequest {
|
||||
'User-Agent': this.client.options.http.headers['User-Agent'],
|
||||
};
|
||||
}
|
||||
if (captchaKey && typeof captchaKey == 'string') {
|
||||
headers['x-captcha-key'] = captchaKey;
|
||||
if (captchaRqtoken) headers['x-captcha-rqtoken'] = captchaRqtoken;
|
||||
}
|
||||
|
||||
let body;
|
||||
if (this.options.files?.length) {
|
||||
@ -98,29 +104,18 @@ class APIRequest {
|
||||
} else {
|
||||
body.append('payload_json', JSON.stringify(this.options.data));
|
||||
}
|
||||
} else if (typeof this.options.body !== 'undefined') {
|
||||
if (this.options.dontUsePayloadJSON) {
|
||||
for (const [key, value] of Object.entries(this.options.body)) body.append(key, value);
|
||||
} else {
|
||||
body.append('payload_json', JSON.stringify(this.options.body));
|
||||
}
|
||||
}
|
||||
headers = Object.assign(headers, body.getHeaders());
|
||||
// eslint-disable-next-line eqeqeq
|
||||
} else if (this.options.data != null) {
|
||||
headers['Content-Type'] = 'application/json';
|
||||
if (captchaKey && typeof captchaKey == 'string') {
|
||||
if (!this.options.data) this.options.data = {};
|
||||
// Delete cookie (https://t.me/DMDGOBugsAndFeatures/626) Wtf Unknown Message Error ???
|
||||
headers.Cookie = undefined;
|
||||
this.options.data.captcha_key = captchaKey;
|
||||
if (captchaRqtoken) this.options.data.captcha_rqtoken = captchaRqtoken;
|
||||
if (this.options.useFormDataPayloadJSON) {
|
||||
body = new FormData();
|
||||
body.append('payload_json', JSON.stringify(this.options.data));
|
||||
headers = Object.assign(headers, body.getHeaders());
|
||||
} else {
|
||||
body = JSON.stringify(this.options.data);
|
||||
headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
body = this.options.data ? JSON.stringify(this.options.data) : undefined;
|
||||
} else if (this.options.body != null) {
|
||||
body = new FormData();
|
||||
body.append('payload_json', JSON.stringify(this.options.body));
|
||||
headers = Object.assign(headers, body.getHeaders());
|
||||
}
|
||||
|
||||
const controller = new AbortController();
|
||||
|
@ -18,6 +18,7 @@ const captchaMessage = [
|
||||
'invalid-input-response',
|
||||
'invalid-response',
|
||||
'You need to update your app',
|
||||
'response-already-used-error',
|
||||
];
|
||||
|
||||
function parseResponse(res) {
|
||||
|
@ -879,7 +879,8 @@ class ApplicationCommand extends Base {
|
||||
let nonce = SnowflakeUtil.generate();
|
||||
const data = getDataPost(optionsData, nonce);
|
||||
await this.client.api.interactions.post({
|
||||
body: data,
|
||||
data,
|
||||
useFormDataPayloadJSON: true,
|
||||
files: attachmentsBuffer,
|
||||
});
|
||||
this.client._interactionCache.set(nonce, {
|
||||
@ -975,7 +976,8 @@ class ApplicationCommand extends Base {
|
||||
data.data.guild_id = message.guildId;
|
||||
}
|
||||
await this.client.api.interactions.post({
|
||||
body: data,
|
||||
data,
|
||||
useFormDataPayloadJSON: true,
|
||||
});
|
||||
this.client._interactionCache.set(nonce, {
|
||||
channelId: message.channelId,
|
||||
|
@ -205,7 +205,7 @@ class Options extends null {
|
||||
system_locale: 'en-US',
|
||||
browser_user_agent: defaultUA,
|
||||
browser_version: '22.3.2',
|
||||
client_build_number: 199933,
|
||||
client_build_number: 201332,
|
||||
native_build_number: 32266,
|
||||
client_event_source: null,
|
||||
design_id: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user