fix: acceptInvite unknown message

but may encounter error rqkey_mismatch
This commit is contained in:
Elysia 2024-01-24 19:53:35 +07:00
parent 7304cb71b4
commit 4a31c662a5
3 changed files with 13 additions and 17 deletions

View File

@ -8,7 +8,6 @@ const makeFetchCookie = require('fetch-cookie');
const FormData = require('form-data'); const FormData = require('form-data');
const fetchOriginal = require('node-fetch'); const fetchOriginal = require('node-fetch');
const { CookieJar } = require('tough-cookie'); const { CookieJar } = require('tough-cookie');
const { UserAgent } = require('../util/Constants');
const cookieJar = new CookieJar(); const cookieJar = new CookieJar();
const fetch = makeFetchCookie(fetchOriginal, cookieJar); const fetch = makeFetchCookie(fetchOriginal, cookieJar);
@ -24,8 +23,9 @@ class APIRequest {
this.options = options; this.options = options;
this.retries = 0; this.retries = 0;
const { userAgentSuffix } = this.client.options; this.fullUserAgent = this.client.options.http.headers['User-Agent'];
this.fullUserAgent = `${UserAgent}${userAgentSuffix.length ? `, ${userAgentSuffix.join(', ')}` : ''}`;
this.client.options.ws.properties.browser_user_agent = this.fullUserAgent;
let queryString = ''; let queryString = '';
if (options.query) { if (options.query) {

View File

@ -9,7 +9,7 @@ const { Error, RangeError, TypeError } = require('../errors');
exports.MaxBulkDeletableMessageAge = 1_209_600_000; exports.MaxBulkDeletableMessageAge = 1_209_600_000;
exports.UserAgent = 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: * The types of WebSocket error codes:

View File

@ -89,8 +89,6 @@ const Intents = require('./Intents');
* @property {number} [retryLimit=1] How many times to retry on 5XX errors * @property {number} [retryLimit=1] How many times to retry on 5XX errors
* (Infinity for an indefinite amount of retries) * (Infinity for an indefinite amount of retries)
* @property {boolean} [failIfNotExists=true] Default value for {@link ReplyMessageOptions#failIfNotExists} * @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 {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 * @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. * 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, restTimeOffset: 500,
restSweepInterval: 60, restSweepInterval: 60,
failIfNotExists: true, failIfNotExists: true,
userAgentSuffix: [],
presence: { status: 'online', since: 0, activities: [], afk: false }, presence: { status: 'online', since: 0, activities: [], afk: false },
sweepers: {}, sweepers: {},
ws: { ws: {
capabilities: 0, // https://discord-userdoccers.vercel.app/topics/gateway#gateway-capabilities capabilities: 0, // https://discord-userdoccers.vercel.app/topics/gateway#gateway-capabilities
properties: { properties: {
os: 'Windows', os: 'Windows',
browser: 'Chrome', browser: 'Discord Client',
device: '', release_channel: 'stable',
client_version: '1.0.9031',
os_version: '10.0.19045',
os_arch: 'x64',
app_arch: 'ia32',
system_locale: 'en-US', system_locale: 'en-US',
browser_user_agent: UserAgent, browser_user_agent: UserAgent,
browser_version: '120.0.0.0', browser_version: '22.3.26',
os_version: '10', client_build_number: 260725,
referrer: '', native_build_number: 42899,
referring_domain: '',
referrer_current: '',
referring_domain_current: '',
release_channel: 'stable',
client_build_number: 260292,
client_event_source: null, client_event_source: null,
}, },
compress: false, compress: false,