feat: remove messageCreateEventGuildTimeout & change UA default

This commit is contained in:
Elysia 2024-01-23 21:03:42 +07:00
parent 87d0334eb8
commit 2472642184
5 changed files with 39 additions and 35 deletions

View File

@ -677,9 +677,6 @@ class Client extends BaseClient {
if (!Array.isArray(options.partials)) {
throw new TypeError('CLIENT_INVALID_OPTION', 'partials', 'an Array');
}
if (typeof options.messageCreateEventGuildTimeout !== 'number' || isNaN(options.messageCreateEventGuildTimeout)) {
throw new TypeError('CLIENT_INVALID_OPTION', 'messageCreateEventGuildTimeout', 'a number');
}
if (typeof options.DMChannelVoiceStatusSync !== 'number' || isNaN(options.DMChannelVoiceStatusSync)) {
throw new TypeError('CLIENT_INVALID_OPTION', 'DMChannelVoiceStatusSync', 'a number');
}

View File

@ -38,23 +38,27 @@ module.exports = (client, { d: data }, shard) => {
// ClientSetting
client.settings._patch(data.user_settings);
Promise.all(
largeGuilds.map(async (guild, index) => {
if (largeGuilds.length) {
client.ws.broadcast({
op: Opcodes.GUILD_SUBSCRIPTIONS,
op: Opcodes.GUILD_SUBSCRIPTIONS_BULK,
d: {
guild_id: guild.id,
subscriptions: largeGuilds.reduce((accumulator, guild) => {
accumulator[guild.id] = {
typing: true,
threads: true,
activities: true,
member_updates: true,
thread_member_lists: [],
members: [],
channels: {},
};
return accumulator;
}, {}),
},
});
client.emit('debug', `[READY] Register guild ${guild.id}`);
await client.sleep(client.options.messageCreateEventGuildTimeout * index);
}),
}
Promise.all(
data.private_channels.map(async (c, index) => {
if (client.options.DMChannelVoiceStatusSync < 1) return;
client.ws.broadcast({

View File

@ -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; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9023 Chrome/108.0.5359.215 Electron/22.3.26 Safari/537.36';
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
/**
* The types of WebSocket error codes:
@ -174,6 +174,8 @@ exports.Status = {
* * SPEED_TEST_DELETE: 33 => Delete a voice speed test.
* * REQUEST_LAST_MESSAGES: 34 => Request last messages for a guild's channels.
* * SEARCH_RECENT_MEMBERS: 35 => ~ Opcode 8 (Member Safety)
* * REQUEST_CHANNEL_STATUSES: 36 => Request Voice Channel status.
* * GUILD_SUBSCRIPTIONS_BULK: 37 => ~ Opcode 14
* @typedef {Object<string, number>} Opcodes
*/
exports.Opcodes = {
@ -212,7 +214,9 @@ exports.Opcodes = {
SPEED_TEST_DELETE: 33, // Payload: null
REQUEST_LAST_MESSAGES: 34, // Payload: { guild_id: string, channel_ids: string[] }
SEARCH_RECENT_MEMBERS: 35, // Payload: { guild_id: string, query: string, continuation_token?: Snowflake }
// Update: 17/7/2023
REQUEST_CHANNEL_STATUSES: 36, // Payload: { guild_id: string } | Response: CHANNEL_STATUSES | { guild_id, channels: { status, id }[] }
GUILD_SUBSCRIPTIONS_BULK: 37, // Payload: { subscriptions: Object<guild_id, { Payload_op14 - guild_id }> } | Response: Opcode 14
// Updated: 23/1/2024
};
/**

View File

@ -49,7 +49,6 @@ const Intents = require('./Intents');
/**
* Options for a client.
* @typedef {Object} ClientOptions
* @property {number} [messageCreateEventGuildTimeout=100] The amount of time in milliseconds that the Client to register for messages with each guild
* @property {number} [DMChannelVoiceStatusSync=0] The amount of time in milliseconds that the Client to register the event with each DM channel (0=Disable)
* @property {number} [captchaRetryLimit=3] Captcha retry limit
* @property {CaptchaSolver} [captchaSolver] Captcha Solver
@ -154,7 +153,6 @@ class Options extends null {
*/
static createDefault() {
return {
messageCreateEventGuildTimeout: 100,
DMChannelVoiceStatusSync: 0,
captchaRetryLimit: 3,
captchaSolver: () => Promise.reject(new Error('CAPTCHA_SOLVER_NOT_IMPLEMENTED')),
@ -181,19 +179,19 @@ class Options extends null {
capabilities: 0, // https://discord-userdoccers.vercel.app/topics/gateway#gateway-capabilities
properties: {
os: 'Windows',
browser: 'Discord Client',
release_channel: 'stable',
client_version: '1.0.9023',
os_version: '10.0.19045',
os_arch: 'x64',
app_arch: 'ia32',
browser: 'Chrome',
device: '',
system_locale: 'en-US',
browser_user_agent: UserAgent,
browser_version: '22.3.26',
client_build_number: 244874,
native_build_number: 39515,
browser_version: '120.0.0.0',
os_version: '10',
referrer: '',
referring_domain: '',
referrer_current: '',
referring_domain_current: '',
release_channel: 'stable',
client_build_number: 260292,
client_event_source: null,
design_id: 0,
},
compress: false,
client_state: {

3
typings/index.d.ts vendored
View File

@ -5188,7 +5188,6 @@ export interface ClientFetchInviteOptions {
export type CaptchaSolver = (captcha: Captcha, UserAgent: string) => Promise<string>;
export interface ClientOptions {
messageCreateEventGuildTimeout?: number;
DMChannelVoiceStatusSync?: number;
captchaRetryLimit?: number;
captchaSolver?: CaptchaSolver;
@ -5496,6 +5495,8 @@ export interface ConstantsOpcodes {
SPEED_TEST_DELETE: 33;
REQUEST_LAST_MESSAGES: 34;
SEARCH_RECENT_MEMBERS: 35;
REQUEST_CHANNEL_STATUSES: 36;
GUILD_SUBSCRIPTIONS_BULK: 37;
}
export interface ConstantsShardEvents {