From 4a31c662a54a1731dcd41c52ab5a2df224c5dd0d Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Wed, 24 Jan 2024 19:53:35 +0700 Subject: [PATCH] fix: acceptInvite unknown message but may encounter error rqkey_mismatch --- src/rest/APIRequest.js | 6 +++--- src/util/Constants.js | 2 +- src/util/Options.js | 22 +++++++++------------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/rest/APIRequest.js b/src/rest/APIRequest.js index b186b80..a095209 100644 --- a/src/rest/APIRequest.js +++ b/src/rest/APIRequest.js @@ -8,7 +8,6 @@ const makeFetchCookie = require('fetch-cookie'); const FormData = require('form-data'); const fetchOriginal = require('node-fetch'); const { CookieJar } = require('tough-cookie'); -const { UserAgent } = require('../util/Constants'); const cookieJar = new CookieJar(); const fetch = makeFetchCookie(fetchOriginal, cookieJar); @@ -24,8 +23,9 @@ class APIRequest { this.options = options; this.retries = 0; - const { userAgentSuffix } = this.client.options; - this.fullUserAgent = `${UserAgent}${userAgentSuffix.length ? `, ${userAgentSuffix.join(', ')}` : ''}`; + this.fullUserAgent = this.client.options.http.headers['User-Agent']; + + this.client.options.ws.properties.browser_user_agent = this.fullUserAgent; let queryString = ''; if (options.query) { diff --git a/src/util/Constants.js b/src/util/Constants.js index a57f7bd..42acd79 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -9,7 +9,7 @@ const { Error, RangeError, TypeError } = require('../errors'); exports.MaxBulkDeletableMessageAge = 1_209_600_000; exports.UserAgent = - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'; + 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9031 Chrome/108.0.5359.215 Electron/22.3.26 Safari/537.36'; /** * The types of WebSocket error codes: diff --git a/src/util/Options.js b/src/util/Options.js index 984ba77..04cb991 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -89,8 +89,6 @@ const Intents = require('./Intents'); * @property {number} [retryLimit=1] How many times to retry on 5XX errors * (Infinity for an indefinite amount of retries) * @property {boolean} [failIfNotExists=true] Default value for {@link ReplyMessageOptions#failIfNotExists} - * @property {string[]} [userAgentSuffix] An array of additional bot info to be appended to the end of the required - * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={ status: 'online', since: 0, activities: [], afk: false }] Presence data to use upon login * @property {number} [waitGuildTimeout=15_000] Time in milliseconds that Clients with the GUILDS intent should wait for * missing guilds to be received before starting the bot. If not specified, the default is 15 seconds. @@ -173,25 +171,23 @@ class Options extends null { restTimeOffset: 500, restSweepInterval: 60, failIfNotExists: true, - userAgentSuffix: [], presence: { status: 'online', since: 0, activities: [], afk: false }, sweepers: {}, ws: { capabilities: 0, // https://discord-userdoccers.vercel.app/topics/gateway#gateway-capabilities properties: { os: 'Windows', - browser: 'Chrome', - device: '', + browser: 'Discord Client', + release_channel: 'stable', + client_version: '1.0.9031', + os_version: '10.0.19045', + os_arch: 'x64', + app_arch: 'ia32', system_locale: 'en-US', browser_user_agent: UserAgent, - browser_version: '120.0.0.0', - os_version: '10', - referrer: '', - referring_domain: '', - referrer_current: '', - referring_domain_current: '', - release_channel: 'stable', - client_build_number: 260292, + browser_version: '22.3.26', + client_build_number: 260725, + native_build_number: 42899, client_event_source: null, }, compress: false,