From 3b846b916976a003b32fd3fe5b11f92d3dcd8b4f Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Tue, 31 Aug 2021 23:03:10 -0700 Subject: [PATCH 01/36] fetch guild timeout amount option --- src/client/websocket/WebSocketShard.js | 16 +++++++++++++--- typings/index.d.ts | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 25f66bbfc4f2..7956f75c0611 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -475,12 +475,22 @@ class WebSocketShard extends EventEmitter { return; } const hasGuildsIntent = new Intents(this.manager.client.options.intents).has(Intents.FLAGS.GUILDS); - // Step 2. Create a 15s timeout that will mark the shard as ready if there are still unavailable guilds + // Step 2. Create a timeout that will mark the shard as ready if there are still unavailable guilds + // * the timeout should be 15 seconds by default, but this can be optionally be changed in the client options + + var guildTimeoutAmount = 15000; + + if (this.manager.client.options.fetchGuildTimeout) { + guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout; + } + + var guildTimeoutAmountInSeconds = guildTimeoutAmount / 1000; + this.readyTimeout = setTimeout( () => { this.debug( `Shard ${hasGuildsIntent ? 'did' : 'will'} not receive any more guild packets` + - `${hasGuildsIntent ? ' in 15 seconds' : ''}.\n Unavailable guild count: ${this.expectedGuilds.size}`, + `${hasGuildsIntent ? `in ${guildTimeoutAmountInSeconds} seconds` : ''}.\n Unavailable guild count: ${this.expectedGuilds.size}`, ); this.readyTimeout = null; @@ -489,7 +499,7 @@ class WebSocketShard extends EventEmitter { this.emit(ShardEvents.ALL_READY, this.expectedGuilds); }, - hasGuildsIntent ? 15000 : 0, + hasGuildsIntent ? guildTimeoutAmount : 0, ).unref(); } diff --git a/typings/index.d.ts b/typings/index.d.ts index 2eacf62eb42e..d606e2c45d47 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3339,6 +3339,7 @@ export interface ClientOptions { userAgentSuffix?: string[]; presence?: PresenceData; intents: BitFieldResolvable; + fetchGuildTimeout?: number; ws?: WebSocketOptions; http?: HTTPOptions; rejectOnRateLimit?: string[] | ((data: RateLimitData) => boolean | Promise); From 6d5a4266df2e36d7c4cb6e498367f55c89493a6f Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 1 Sep 2021 09:53:35 -0700 Subject: [PATCH 02/36] Update src/client/websocket/WebSocketShard.js Co-authored-by: D Trombett <73136330+DTrombett@users.noreply.github.com> --- src/client/websocket/WebSocketShard.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 7956f75c0611..f356618bf177 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -478,13 +478,7 @@ class WebSocketShard extends EventEmitter { // Step 2. Create a timeout that will mark the shard as ready if there are still unavailable guilds // * the timeout should be 15 seconds by default, but this can be optionally be changed in the client options - var guildTimeoutAmount = 15000; - - if (this.manager.client.options.fetchGuildTimeout) { - guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout; - } - - var guildTimeoutAmountInSeconds = guildTimeoutAmount / 1000; + const guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout || 1500; this.readyTimeout = setTimeout( () => { From 08a088e541d8bb4016e33ffee51ea33d48424bec Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 1 Sep 2021 11:47:46 -0700 Subject: [PATCH 03/36] Options for client --- src/util/Options.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/Options.js b/src/util/Options.js index 7f45f9d401a9..2b3d2c879915 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -69,6 +69,7 @@ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection + * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should hang and wait for missing guilds to be recieved before starting. Default is 15 seconds. * @property {WebsocketOptions} [ws] Options for the WebSocket * @property {HTTPOptions} [http] HTTP options */ From 8805731e693d3b40fa7939d2fbfcb41a1f109e95 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 1 Sep 2021 11:49:26 -0700 Subject: [PATCH 04/36] change to milliseconds --- src/client/websocket/WebSocketShard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index f356618bf177..399fe1d6bb77 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -476,7 +476,7 @@ class WebSocketShard extends EventEmitter { } const hasGuildsIntent = new Intents(this.manager.client.options.intents).has(Intents.FLAGS.GUILDS); // Step 2. Create a timeout that will mark the shard as ready if there are still unavailable guilds - // * the timeout should be 15 seconds by default, but this can be optionally be changed in the client options + // * the timeout should be 15 seconds by default, but this can be optionally be changed in the client options via fetchGuildTimeout const guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout || 1500; @@ -484,7 +484,7 @@ class WebSocketShard extends EventEmitter { () => { this.debug( `Shard ${hasGuildsIntent ? 'did' : 'will'} not receive any more guild packets` + - `${hasGuildsIntent ? `in ${guildTimeoutAmountInSeconds} seconds` : ''}.\n Unavailable guild count: ${this.expectedGuilds.size}`, + `${hasGuildsIntent ? `in ${guildTimeoutAmount} milliseconds` : ''}.\n Unavailable guild count: ${this.expectedGuilds.size}`, ); this.readyTimeout = null; From 2980212af95ac37428f6898c82227651ff15b7ea Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 1 Sep 2021 11:50:04 -0700 Subject: [PATCH 05/36] additional timeout what zero means --- src/client/websocket/WebSocketShard.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 399fe1d6bb77..248f700701b7 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -477,6 +477,7 @@ class WebSocketShard extends EventEmitter { const hasGuildsIntent = new Intents(this.manager.client.options.intents).has(Intents.FLAGS.GUILDS); // Step 2. Create a timeout that will mark the shard as ready if there are still unavailable guilds // * the timeout should be 15 seconds by default, but this can be optionally be changed in the client options via fetchGuildTimeout + // * a timeout time of zero will skip this timeout const guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout || 1500; From aa5b300b700f86f913650d61b1174efc5c93f11e Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 1 Sep 2021 12:10:20 -0700 Subject: [PATCH 06/36] if not specified note --- src/util/Options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/Options.js b/src/util/Options.js index 2b3d2c879915..94b5871bff44 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -69,7 +69,7 @@ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection - * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should hang and wait for missing guilds to be recieved before starting. Default is 15 seconds. + * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should hang and wait for missing guilds to be recieved before starting the bot. If not specified, the default is 15 seconds. * @property {WebsocketOptions} [ws] Options for the WebSocket * @property {HTTPOptions} [http] HTTP options */ From 0650264c3679615ed8b72e6447f4989cdc289340 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 1 Sep 2021 13:36:28 -0700 Subject: [PATCH 07/36] Update src/client/websocket/WebSocketShard.js Co-authored-by: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com> --- src/client/websocket/WebSocketShard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 248f700701b7..1762b131c692 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -485,7 +485,7 @@ class WebSocketShard extends EventEmitter { () => { this.debug( `Shard ${hasGuildsIntent ? 'did' : 'will'} not receive any more guild packets` + - `${hasGuildsIntent ? `in ${guildTimeoutAmount} milliseconds` : ''}.\n Unavailable guild count: ${this.expectedGuilds.size}`, + `${hasGuildsIntent ? ` in ${guildTimeoutAmount} ms` : ''}.\n Unavailable guild count: ${this.expectedGuilds.size}`, ); this.readyTimeout = null; From 895da0d5779b7c29f7939d63aef16a5e9970d894 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 1 Sep 2021 13:54:10 -0700 Subject: [PATCH 08/36] fix line length lint issue --- src/client/websocket/WebSocketShard.js | 6 ++++-- src/util/Options.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 1762b131c692..5983fb6cc0b9 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -476,7 +476,8 @@ class WebSocketShard extends EventEmitter { } const hasGuildsIntent = new Intents(this.manager.client.options.intents).has(Intents.FLAGS.GUILDS); // Step 2. Create a timeout that will mark the shard as ready if there are still unavailable guilds - // * the timeout should be 15 seconds by default, but this can be optionally be changed in the client options via fetchGuildTimeout + // * the timeout should be 15 seconds by default + // * this can be optionally be changed in the client options via fetchGuildTimeout // * a timeout time of zero will skip this timeout const guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout || 1500; @@ -485,7 +486,8 @@ class WebSocketShard extends EventEmitter { () => { this.debug( `Shard ${hasGuildsIntent ? 'did' : 'will'} not receive any more guild packets` + - `${hasGuildsIntent ? ` in ${guildTimeoutAmount} ms` : ''}.\n Unavailable guild count: ${this.expectedGuilds.size}`, + `${hasGuildsIntent ? ` in ${guildTimeoutAmount} ms` : ''}.\n` + + `Unavailable guild count: ${this.expectedGuilds.size}`, ); this.readyTimeout = null; diff --git a/src/util/Options.js b/src/util/Options.js index 94b5871bff44..98812cda4850 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -69,7 +69,9 @@ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection - * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should hang and wait for missing guilds to be recieved before starting the bot. If not specified, the default is 15 seconds. + * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should hang + * and wait for missing guilds to be recieved before starting the bot. + * If not specified, the default is 15 seconds. * @property {WebsocketOptions} [ws] Options for the WebSocket * @property {HTTPOptions} [http] HTTP options */ From ce80fc80074ad8f7a34dd9fe9c1a84adc3bf6b5c Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:26:57 -0700 Subject: [PATCH 09/36] prettier style formatting --- src/client/websocket/WebSocketShard.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 5983fb6cc0b9..14a68dda3650 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -486,8 +486,9 @@ class WebSocketShard extends EventEmitter { () => { this.debug( `Shard ${hasGuildsIntent ? 'did' : 'will'} not receive any more guild packets` + - `${hasGuildsIntent ? ` in ${guildTimeoutAmount} ms` : ''}.\n` + - `Unavailable guild count: ${this.expectedGuilds.size}`, + `${hasGuildsIntent ? ` in ${guildTimeoutAmount} ms` : ''}.\nUnavailable guild count: ${ + this.expectedGuilds.size + }`, ); this.readyTimeout = null; From 32f64597882d7c6cf815fffedfe6cc6a286bcecb Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:33:02 -0700 Subject: [PATCH 10/36] Add validation --- src/client/Client.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/Client.js b/src/client/Client.js index 5550a371ed65..0038f8deda07 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -567,6 +567,9 @@ class Client extends BaseClient { if (!Array.isArray(options.partials)) { throw new TypeError('CLIENT_INVALID_OPTION', 'partials', 'an Array'); } + if (typeof options.fetchGuildTimeout !== 'number' || isNaN(options.fetchGuildTimeout)) { + throw new TypeError('CLIENT_INVALID_OPTION', 'fetchGuildTimeout', 'a number'); + } if (typeof options.restWsBridgeTimeout !== 'number' || isNaN(options.restWsBridgeTimeout)) { throw new TypeError('CLIENT_INVALID_OPTION', 'restWsBridgeTimeout', 'a number'); } From 3a2c32abb7d1a5c327bf19361a518562d0d2001b Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:33:09 -0700 Subject: [PATCH 11/36] Add default value --- src/util/Options.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/Options.js b/src/util/Options.js index 98812cda4850..66ff326b13e5 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -127,6 +127,7 @@ class Options extends null { failIfNotExists: true, userAgentSuffix: [], presence: {}, + fetchGuildTimeout: 15000, ws: { large_threshold: 50, compress: false, From 5373716a8e547fbf03f545c687ff21b7e4ac15d9 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 1 Sep 2021 16:09:16 -0700 Subject: [PATCH 12/36] Update src/client/websocket/WebSocketShard.js Co-authored-by: monbrey --- src/client/websocket/WebSocketShard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 14a68dda3650..0162f6027b61 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -480,7 +480,7 @@ class WebSocketShard extends EventEmitter { // * this can be optionally be changed in the client options via fetchGuildTimeout // * a timeout time of zero will skip this timeout - const guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout || 1500; + const guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout ?? 15000; this.readyTimeout = setTimeout( () => { From a8e686ed8c4665deadc778c5ae4c65a3c38f816a Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Thu, 2 Sep 2021 15:13:02 -0700 Subject: [PATCH 13/36] Update src/util/Options.js Co-authored-by: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com> --- src/util/Options.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/Options.js b/src/util/Options.js index 66ff326b13e5..3081dc7b50c2 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -69,9 +69,7 @@ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection - * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should hang - * and wait for missing guilds to be recieved before starting the bot. - * If not specified, the default is 15 seconds. + * @property {number} [fetchGuildTimeout=15000] Time in milliseconds to wait for missing guilds to be received before marking as ready (0 to skip this timeout) * @property {WebsocketOptions} [ws] Options for the WebSocket * @property {HTTPOptions} [http] HTTP options */ From 4460fdcadcb051d8dd4b1586b0178e29ac2ccfdf Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Thu, 2 Sep 2021 22:04:50 -0700 Subject: [PATCH 14/36] fix doccumentation --- src/util/Options.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/Options.js b/src/util/Options.js index 3081dc7b50c2..c3f0adb7f473 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -69,7 +69,10 @@ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection - * @property {number} [fetchGuildTimeout=15000] Time in milliseconds to wait for missing guilds to be received before marking as ready (0 to skip this timeout) + * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should hang + * and wait for missing guilds to be recieved before starting the bot + * If not specified, the default is 15 seconds. + * (0 to skip this timeout) * @property {WebsocketOptions} [ws] Options for the WebSocket * @property {HTTPOptions} [http] HTTP options */ From e23cb90e609c50333020c710d092ae07e0bf9ac8 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Fri, 3 Sep 2021 14:41:37 -0700 Subject: [PATCH 15/36] Update src/client/websocket/WebSocketShard.js Co-authored-by: Vlad Frangu --- src/client/websocket/WebSocketShard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 0162f6027b61..fb7b0f980643 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -477,7 +477,7 @@ class WebSocketShard extends EventEmitter { const hasGuildsIntent = new Intents(this.manager.client.options.intents).has(Intents.FLAGS.GUILDS); // Step 2. Create a timeout that will mark the shard as ready if there are still unavailable guilds // * the timeout should be 15 seconds by default - // * this can be optionally be changed in the client options via fetchGuildTimeout + // * This can be optionally be changed in the client options via the `fetchGuildTimeout` option // * a timeout time of zero will skip this timeout const guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout ?? 15000; From 373f0d902c3caa25b2276131396474e15c29e30b Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Fri, 3 Sep 2021 14:41:55 -0700 Subject: [PATCH 16/36] Update src/util/Options.js Co-authored-by: Vlad Frangu --- src/util/Options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/Options.js b/src/util/Options.js index c3f0adb7f473..cd1c6d8ca630 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -69,7 +69,7 @@ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection - * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should hang + * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that clients with the `GUILDS` intent should hang * and wait for missing guilds to be recieved before starting the bot * If not specified, the default is 15 seconds. * (0 to skip this timeout) From 3e24cfc646e3ad6b575e5ea32ff0019cc9e07336 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Fri, 3 Sep 2021 18:57:06 -0700 Subject: [PATCH 17/36] Update src/util/Options.js Co-authored-by: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com> --- src/util/Options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/Options.js b/src/util/Options.js index cd1c6d8ca630..0130e19c62c0 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -70,7 +70,7 @@ * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that clients with the `GUILDS` intent should hang - * and wait for missing guilds to be recieved before starting the bot + * and wait for missing guilds to be received before starting the bot * If not specified, the default is 15 seconds. * (0 to skip this timeout) * @property {WebsocketOptions} [ws] Options for the WebSocket From 10f0fcbafa05425b97ec3a72c6d6cbed54b2694f Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Fri, 3 Sep 2021 19:02:38 -0700 Subject: [PATCH 18/36] Update src/util/Options.js Co-authored-by: Vlad Frangu --- src/util/Options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/Options.js b/src/util/Options.js index 0130e19c62c0..4d8f35bfbe7b 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -128,7 +128,7 @@ class Options extends null { failIfNotExists: true, userAgentSuffix: [], presence: {}, - fetchGuildTimeout: 15000, + fetchGuildTimeout: 15_000, ws: { large_threshold: 50, compress: false, From 8b43ac7a2254f8980e9949feaacc0f68ed001e99 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Fri, 3 Sep 2021 19:06:29 -0700 Subject: [PATCH 19/36] Update src/client/websocket/WebSocketShard.js Co-authored-by: Vlad Frangu --- src/client/websocket/WebSocketShard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index fb7b0f980643..6734daaec4b8 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -476,7 +476,7 @@ class WebSocketShard extends EventEmitter { } const hasGuildsIntent = new Intents(this.manager.client.options.intents).has(Intents.FLAGS.GUILDS); // Step 2. Create a timeout that will mark the shard as ready if there are still unavailable guilds - // * the timeout should be 15 seconds by default + // * The timeout is 15 seconds by default // * This can be optionally be changed in the client options via the `fetchGuildTimeout` option // * a timeout time of zero will skip this timeout From 032c11aabe1bac89a8e565b33fb99f5d723f89b6 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Fri, 3 Sep 2021 20:49:57 -0700 Subject: [PATCH 20/36] add documentation on what skipping timeout means --- src/client/websocket/WebSocketShard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index e597407d537d..7519101b9163 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -478,7 +478,7 @@ class WebSocketShard extends EventEmitter { // Step 2. Create a timeout that will mark the shard as ready if there are still unavailable guilds // * The timeout is 15 seconds by default // * This can be optionally be changed in the client options via the `fetchGuildTimeout` option - // * a timeout time of zero will skip this timeout + // * a timeout time of zero will skip this timeout, which potentially could cause the Client to miss guilds. const guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout ?? 15000; From 8ef317a3ff4baaeff4a8321b764e6df974217689 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Sun, 5 Sep 2021 12:15:30 -0700 Subject: [PATCH 21/36] Update src/client/websocket/WebSocketShard.js Co-authored-by: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com> --- src/client/websocket/WebSocketShard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 7519101b9163..bfee6ca94592 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -480,7 +480,7 @@ class WebSocketShard extends EventEmitter { // * This can be optionally be changed in the client options via the `fetchGuildTimeout` option // * a timeout time of zero will skip this timeout, which potentially could cause the Client to miss guilds. - const guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout ?? 15000; + const guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout; this.readyTimeout = setTimeout( () => { From 032fd105136ed64751b27055ca9c4883d234b2b9 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Mon, 6 Sep 2021 01:01:39 -0700 Subject: [PATCH 22/36] Update src/util/Options.js Co-authored-by: Yoshida Tomio --- src/util/Options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/Options.js b/src/util/Options.js index ad9ecc5285e6..6b09ad69477d 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -69,7 +69,7 @@ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection - * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that clients with the `GUILDS` intent should hang + * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that bots with the `GUILDS` intent should hang * and wait for missing guilds to be received before starting the bot * If not specified, the default is 15 seconds. * (0 to skip this timeout) From 2bae858a6bd3d9822afce9eb1baf2c76ff50a7ee Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:49:45 -0700 Subject: [PATCH 23/36] Update src/util/Options.js Co-authored-by: SpaceEEC --- src/util/Options.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/Options.js b/src/util/Options.js index 6b09ad69477d..f38fa082ad56 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -69,10 +69,8 @@ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection - * @property {number} [fetchGuildTimeout=15000] Time in milliseconds that bots with the `GUILDS` intent should hang - * and wait for missing guilds to be received before starting the bot - * If not specified, the default is 15 seconds. - * (0 to skip this timeout) + * @property {number} [waitGuildTimeout=15000] Time in milliseconds that bots with the `GUILDS` intent should wait for + * initial guild's data to be received before emitting ready. (0 to not wait) * @property {WebsocketOptions} [ws] Options for the WebSocket * @property {HTTPOptions} [http] HTTP options */ From e52ba3d76ea777a120edb6ae6c46059b322f7e97 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:53:05 -0700 Subject: [PATCH 24/36] Update Client.js --- src/client/Client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index d74179a09c1e..274f31877ead 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -567,8 +567,8 @@ class Client extends BaseClient { if (!Array.isArray(options.partials)) { throw new TypeError('CLIENT_INVALID_OPTION', 'partials', 'an Array'); } - if (typeof options.fetchGuildTimeout !== 'number' || isNaN(options.fetchGuildTimeout)) { - throw new TypeError('CLIENT_INVALID_OPTION', 'fetchGuildTimeout', 'a number'); + if (typeof options.waitGuildTimeout !== 'number' || isNaN(options.waitGuildTimeout)) { + throw new TypeError('CLIENT_INVALID_OPTION', 'waitGuildTimeout', 'a number'); } if (typeof options.restWsBridgeTimeout !== 'number' || isNaN(options.restWsBridgeTimeout)) { throw new TypeError('CLIENT_INVALID_OPTION', 'restWsBridgeTimeout', 'a number'); From c2a0fba52e302e0ef4676502b7659d4f10613fec Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:56:02 -0700 Subject: [PATCH 25/36] change name --- src/util/Options.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/util/Options.js b/src/util/Options.js index f38fa082ad56..02757aed87da 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -69,8 +69,7 @@ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection - * @property {number} [waitGuildTimeout=15000] Time in milliseconds that bots with the `GUILDS` intent should wait for - * initial guild's data to be received before emitting ready. (0 to not wait) + * @property {number} [waitGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should wait for missing guilds to be recieved before starting the bot. If not specified, the default is 15 seconds. * @property {WebsocketOptions} [ws] Options for the WebSocket * @property {HTTPOptions} [http] HTTP options */ @@ -117,8 +116,8 @@ class Options extends null { messageSweepInterval: 0, invalidRequestWarningInterval: 0, partials: [], - restWsBridgeTimeout: 5_000, - restRequestTimeout: 15_000, + restWsBridgeTimeout: 5000, + restRequestTimeout: 15000, restGlobalRateLimit: 0, retryLimit: 1, restTimeOffset: 500, @@ -126,7 +125,6 @@ class Options extends null { failIfNotExists: true, userAgentSuffix: [], presence: {}, - fetchGuildTimeout: 15_000, ws: { large_threshold: 50, compress: false, From e16ec48cc8bf4f79e86ffcb82e370121dfb7acd9 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:58:08 -0700 Subject: [PATCH 26/36] change fetch to wait --- src/client/websocket/WebSocketShard.js | 2 +- typings/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index bfee6ca94592..be475feb1060 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -480,7 +480,7 @@ class WebSocketShard extends EventEmitter { // * This can be optionally be changed in the client options via the `fetchGuildTimeout` option // * a timeout time of zero will skip this timeout, which potentially could cause the Client to miss guilds. - const guildTimeoutAmount = this.manager.client.options.fetchGuildTimeout; + const guildTimeoutAmount = this.manager.client.options.waitGuildTimeout; this.readyTimeout = setTimeout( () => { diff --git a/typings/index.d.ts b/typings/index.d.ts index 395af96134ee..18aca1bb9626 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3353,7 +3353,7 @@ export interface ClientOptions { userAgentSuffix?: string[]; presence?: PresenceData; intents: BitFieldResolvable; - fetchGuildTimeout?: number; + waitGuildTimeout?: number; ws?: WebSocketOptions; http?: HTTPOptions; rejectOnRateLimit?: string[] | ((data: RateLimitData) => boolean | Promise); From 5613b9fcf784247f2d6e8c1b0ff018baf9ce5f74 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:58:42 -0700 Subject: [PATCH 27/36] change name again --- src/client/websocket/WebSocketShard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index be475feb1060..2b5afba4466f 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -477,7 +477,7 @@ class WebSocketShard extends EventEmitter { const hasGuildsIntent = new Intents(this.manager.client.options.intents).has(Intents.FLAGS.GUILDS); // Step 2. Create a timeout that will mark the shard as ready if there are still unavailable guilds // * The timeout is 15 seconds by default - // * This can be optionally be changed in the client options via the `fetchGuildTimeout` option + // * This can be optionally be changed in the client options via the `waitGuildTimeout` option // * a timeout time of zero will skip this timeout, which potentially could cause the Client to miss guilds. const guildTimeoutAmount = this.manager.client.options.waitGuildTimeout; From 752c39304f3bae6c7f42eda121d624a9aa628e8e Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Mon, 20 Sep 2021 23:01:36 -0700 Subject: [PATCH 28/36] Update src/client/websocket/WebSocketShard.js Co-authored-by: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com> --- src/client/websocket/WebSocketShard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 2b5afba4466f..99b10e2707cf 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -480,7 +480,7 @@ class WebSocketShard extends EventEmitter { // * This can be optionally be changed in the client options via the `waitGuildTimeout` option // * a timeout time of zero will skip this timeout, which potentially could cause the Client to miss guilds. - const guildTimeoutAmount = this.manager.client.options.waitGuildTimeout; + const { waitGuildTimeout } = this.manager.client.options; this.readyTimeout = setTimeout( () => { From 3358b18ded60e6725df1a07ee01814a2699e781d Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Mon, 20 Sep 2021 23:01:55 -0700 Subject: [PATCH 29/36] Update src/client/websocket/WebSocketShard.js Co-authored-by: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com> --- src/client/websocket/WebSocketShard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 99b10e2707cf..5df123846271 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -486,7 +486,7 @@ class WebSocketShard extends EventEmitter { () => { this.debug( `Shard ${hasGuildsIntent ? 'did' : 'will'} not receive any more guild packets` + - `${hasGuildsIntent ? ` in ${guildTimeoutAmount} ms` : ''}.\nUnavailable guild count: ${ + `${hasGuildsIntent ? ` in ${waitGuildTimeout} ms` : ''}.\nUnavailable guild count: ${ this.expectedGuilds.size }`, ); From 0373bbaf607ef68317e19118a76e838bbdae0679 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Mon, 20 Sep 2021 23:02:08 -0700 Subject: [PATCH 30/36] Update src/client/websocket/WebSocketShard.js Co-authored-by: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com> --- src/client/websocket/WebSocketShard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 5df123846271..78b784d8fc67 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -497,7 +497,7 @@ class WebSocketShard extends EventEmitter { this.emit(ShardEvents.ALL_READY, this.expectedGuilds); }, - hasGuildsIntent ? guildTimeoutAmount : 0, + hasGuildsIntent ? waitGuildTimeout : 0, ).unref(); } From 477a6be70c24af91bd1afc644b1e25684611bf25 Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Sun, 3 Oct 2021 13:56:22 +0200 Subject: [PATCH 31/36] apply suggestions from code review --- src/util/Options.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util/Options.js b/src/util/Options.js index 02757aed87da..44c8e600d890 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -69,7 +69,8 @@ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection - * @property {number} [waitGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should wait for missing guilds to be recieved before starting the bot. If not specified, the default is 15 seconds. + * @property {number} [waitGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should wait for + * missing guilds to be recieved before starting the bot. If not specified, the default is 15 seconds. * @property {WebsocketOptions} [ws] Options for the WebSocket * @property {HTTPOptions} [http] HTTP options */ @@ -116,8 +117,8 @@ class Options extends null { messageSweepInterval: 0, invalidRequestWarningInterval: 0, partials: [], - restWsBridgeTimeout: 5000, - restRequestTimeout: 15000, + restWsBridgeTimeout: 5_000, + restRequestTimeout: 15_000, restGlobalRateLimit: 0, retryLimit: 1, restTimeOffset: 500, From f78cd74fd8f34eac089648ef41d796c9f9a6d84b Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Fri, 29 Oct 2021 21:42:40 -0700 Subject: [PATCH 32/36] Update WebSocketShard.js --- src/client/websocket/WebSocketShard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 78b784d8fc67..b33a9787b4c7 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -477,7 +477,7 @@ class WebSocketShard extends EventEmitter { const hasGuildsIntent = new Intents(this.manager.client.options.intents).has(Intents.FLAGS.GUILDS); // Step 2. Create a timeout that will mark the shard as ready if there are still unavailable guilds // * The timeout is 15 seconds by default - // * This can be optionally be changed in the client options via the `waitGuildTimeout` option + // * This can be optionally changed in the client options via the `waitGuildTimeout` option // * a timeout time of zero will skip this timeout, which potentially could cause the Client to miss guilds. const { waitGuildTimeout } = this.manager.client.options; From 8f31b9fea0d9af368f09f99254f6392c4753b706 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Fri, 29 Oct 2021 21:56:14 -0700 Subject: [PATCH 33/36] Update Options.js --- src/util/Options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/Options.js b/src/util/Options.js index 44c8e600d890..ce6d9b12fedd 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -69,7 +69,7 @@ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header * @property {PresenceData} [presence={}] Presence data to use upon login * @property {IntentsResolvable} intents Intents to enable for this connection - * @property {number} [waitGuildTimeout=15000] 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 recieved before starting the bot. If not specified, the default is 15 seconds. * @property {WebsocketOptions} [ws] Options for the WebSocket * @property {HTTPOptions} [http] HTTP options From dfeaa937500672b8abd8a5a156e238593a2d5a6f Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Sat, 27 Nov 2021 18:11:41 -0800 Subject: [PATCH 34/36] Update BaseGuild.js --- src/structures/BaseGuild.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/structures/BaseGuild.js b/src/structures/BaseGuild.js index 05e029bb74a3..a1f2fdc42636 100644 --- a/src/structures/BaseGuild.js +++ b/src/structures/BaseGuild.js @@ -61,10 +61,14 @@ class BaseGuild extends Base { * @readonly */ get nameAcronym() { - return this.name + if (this.name) { + return this.name .replace(/'s /g, ' ') .replace(/\w+/g, e => e[0]) .replace(/\s/g, ''); + } else { + return null; + } } /** From 0e35afaa06678e3e0820a4df992e5a7834b51186 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Mon, 29 Nov 2021 14:21:36 -0800 Subject: [PATCH 35/36] Update BaseGuild.js --- src/structures/BaseGuild.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/structures/BaseGuild.js b/src/structures/BaseGuild.js index a1f2fdc42636..05e029bb74a3 100644 --- a/src/structures/BaseGuild.js +++ b/src/structures/BaseGuild.js @@ -61,14 +61,10 @@ class BaseGuild extends Base { * @readonly */ get nameAcronym() { - if (this.name) { - return this.name + return this.name .replace(/'s /g, ' ') .replace(/\w+/g, e => e[0]) .replace(/\s/g, ''); - } else { - return null; - } } /** From c94018a2f824535022b42a2f40238da693bd6dc0 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Thu, 23 Dec 2021 14:02:04 -0800 Subject: [PATCH 36/36] Update Options.js --- src/util/Options.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/Options.js b/src/util/Options.js index 2f6d51451f37..3ad73d1142f2 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -112,6 +112,7 @@ class Options extends null { */ static createDefault() { return { + waitGuildTimeout: 15_000, shardCount: 1, makeCache: this.cacheWithLimits(this.defaultMakeCacheSettings), messageCacheLifetime: 0,