From 86b95be8a53c87dcdb66a596a4043b31454fd3ef Mon Sep 17 00:00:00 2001 From: Idris Date: Sun, 11 Sep 2022 19:07:19 +0200 Subject: [PATCH 1/5] fix(ClientOptions): make ClientOptions#intents returns an instance of IntentsBitField --- packages/discord.js/src/client/Client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/src/client/Client.js b/packages/discord.js/src/client/Client.js index 69ccb58b48f1..c9950e9f45f0 100644 --- a/packages/discord.js/src/client/Client.js +++ b/packages/discord.js/src/client/Client.js @@ -479,7 +479,7 @@ class Client extends BaseClient { if (typeof options.intents === 'undefined') { throw new TypeError(ErrorCodes.ClientMissingIntents); } else { - options.intents = IntentsBitField.resolve(options.intents); + options.intents = new IntentsBitField(options.intents).freeze(); } if (typeof options.shardCount !== 'number' || isNaN(options.shardCount) || options.shardCount < 1) { throw new TypeError(ErrorCodes.ClientInvalidOption, 'shardCount', 'a number greater than or equal to 1'); From fede5a41ab57ccd44449389b75dd167462529986 Mon Sep 17 00:00:00 2001 From: Idris Date: Sun, 11 Sep 2022 19:32:16 +0200 Subject: [PATCH 2/5] fix: client.options --- packages/discord.js/src/client/websocket/WebSocketShard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/discord.js/src/client/websocket/WebSocketShard.js b/packages/discord.js/src/client/websocket/WebSocketShard.js index 392fc5cc0ad7..4779340a12c7 100644 --- a/packages/discord.js/src/client/websocket/WebSocketShard.js +++ b/packages/discord.js/src/client/websocket/WebSocketShard.js @@ -512,7 +512,7 @@ class WebSocketShard extends EventEmitter { this.emit(WebSocketShardEvents.AllReady); return; } - const hasGuildsIntent = new IntentsBitField(this.manager.client.options.intents).has(GatewayIntentBits.Guilds); + const hasGuildsIntent = this.manager.client.options.intents.has(GatewayIntentBits.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 changed in the client options via the `waitGuildTimeout` option @@ -687,7 +687,7 @@ class WebSocketShard extends EventEmitter { // Clone the identify payload and assign the token and shard info const d = { ...client.options.ws, - intents: IntentsBitField.resolve(client.options.intents), + intents: client.options.intents.bitfield, token: client.token, shard: [this.id, Number(client.options.shardCount)], }; From 9cf89a4b1fdad9da754096e6c4633871c67fde92 Mon Sep 17 00:00:00 2001 From: Idris Date: Sun, 11 Sep 2022 19:40:13 +0200 Subject: [PATCH 3/5] fix(types): Client#options --- packages/discord.js/typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index f10619348960..3e80a138ab60 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -754,7 +754,7 @@ export class Client extends BaseClient { public channels: ChannelManager; public get emojis(): BaseGuildEmojiManager; public guilds: GuildManager; - public options: ClientOptions; + public options: Omit & { intents: IntentsBitField }; public get readyAt(): If; public readyTimestamp: If; public sweepers: Sweepers; From 43dd9146f09359bb444de04368ca7a730e64ed10 Mon Sep 17 00:00:00 2001 From: Idris Date: Thu, 15 Sep 2022 21:34:56 +0200 Subject: [PATCH 4/5] fix(WebSocketShard): remove require for IntentsBitField --- packages/discord.js/src/client/websocket/WebSocketShard.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/discord.js/src/client/websocket/WebSocketShard.js b/packages/discord.js/src/client/websocket/WebSocketShard.js index 4779340a12c7..5683938f939d 100644 --- a/packages/discord.js/src/client/websocket/WebSocketShard.js +++ b/packages/discord.js/src/client/websocket/WebSocketShard.js @@ -5,7 +5,6 @@ const { setTimeout, setInterval, clearTimeout, clearInterval } = require('node:t const { GatewayDispatchEvents, GatewayIntentBits, GatewayOpcodes } = require('discord-api-types/v10'); const WebSocket = require('../../WebSocket'); const Events = require('../../util/Events'); -const IntentsBitField = require('../../util/IntentsBitField'); const Status = require('../../util/Status'); const WebSocketShardEvents = require('../../util/WebSocketShardEvents'); From 03b8ee6526a3741a301aab87243f119060b05dc7 Mon Sep 17 00:00:00 2001 From: Idris Date: Sun, 9 Oct 2022 21:32:25 +0200 Subject: [PATCH 5/5] fix(eslint): yarn format --- packages/discord.js/typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index c7956661496f..c4f35ffb845d 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -756,7 +756,7 @@ export class Client extends BaseClient { public channels: ChannelManager; public get emojis(): BaseGuildEmojiManager; public guilds: GuildManager; - public options: Omit & { intents: IntentsBitField }; + public options: Omit & { intents: IntentsBitField }; public get readyAt(): If; public readyTimestamp: If; public sweepers: Sweepers;