From 70b1bc1dc58177360e6907b2e42fc8bc9a7e6009 Mon Sep 17 00:00:00 2001 From: MARCROCK22 <57925328+MARCROCK22@users.noreply.github.com> Date: Thu, 17 Oct 2024 12:10:16 -0400 Subject: [PATCH] fix: use an array instead of a Set (#280) --- package.json | 4 +- pnpm-lock.yaml | 166 ++++++++++++++++++------------------- src/client/client.ts | 5 +- src/client/workerclient.ts | 57 +++++++------ 4 files changed, 115 insertions(+), 117 deletions(-) diff --git a/package.json b/package.json index 6a878f7..cd9e827 100644 --- a/package.json +++ b/package.json @@ -24,11 +24,11 @@ "@biomejs/biome": "1.9.3", "@commitlint/cli": "^19.5.0", "@commitlint/config-conventional": "^19.5.0", - "@types/node": "^22.7.5", + "@types/node": "^22.7.6", "husky": "^9.1.6", "lint-staged": "^15.2.10", "typescript": "^5.6.3", - "vitest": "^2.1.2" + "vitest": "^2.1.3" }, "homepage": "https://seyfert.dev", "repository": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 53c8c02..b3b336c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,13 +13,13 @@ importers: version: 1.9.3 '@commitlint/cli': specifier: ^19.5.0 - version: 19.5.0(@types/node@22.7.5)(typescript@5.6.3) + version: 19.5.0(@types/node@22.7.6)(typescript@5.6.3) '@commitlint/config-conventional': specifier: ^19.5.0 version: 19.5.0 '@types/node': - specifier: ^22.7.5 - version: 22.7.5 + specifier: ^22.7.6 + version: 22.7.6 husky: specifier: ^9.1.6 version: 9.1.6 @@ -30,8 +30,8 @@ importers: specifier: ^5.6.3 version: 5.6.3 vitest: - specifier: ^2.1.2 - version: 2.1.2(@types/node@22.7.5) + specifier: ^2.1.3 + version: 2.1.3(@types/node@22.7.6) packages: @@ -396,16 +396,16 @@ packages: '@types/estree@1.0.6': resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} - '@types/node@22.7.5': - resolution: {integrity: sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==} + '@types/node@22.7.6': + resolution: {integrity: sha512-/d7Rnj0/ExXDMcioS78/kf1lMzYk4BZV8MZGTBKzTGZ6/406ukkbYlIsZmMPhcR5KlkunDHQLrtAVmSq7r+mSw==} - '@vitest/expect@2.1.2': - resolution: {integrity: sha512-FEgtlN8mIUSEAAnlvn7mP8vzaWhEaAEvhSXCqrsijM7K6QqjB11qoRZYEd4AKSCDz8p0/+yH5LzhZ47qt+EyPg==} + '@vitest/expect@2.1.3': + resolution: {integrity: sha512-SNBoPubeCJhZ48agjXruCI57DvxcsivVDdWz+SSsmjTT4QN/DfHk3zB/xKsJqMs26bLZ/pNRLnCf0j679i0uWQ==} - '@vitest/mocker@2.1.2': - resolution: {integrity: sha512-ExElkCGMS13JAJy+812fw1aCv2QO/LBK6CyO4WOPAzLTmve50gydOlWhgdBJPx2ztbADUq3JVI0C5U+bShaeEA==} + '@vitest/mocker@2.1.3': + resolution: {integrity: sha512-eSpdY/eJDuOvuTA3ASzCjdithHa+GIF1L4PqtEELl6Qa3XafdMLBpBlZCIUCX2J+Q6sNmjmxtosAG62fK4BlqQ==} peerDependencies: - '@vitest/spy': 2.1.2 + '@vitest/spy': 2.1.3 msw: ^2.3.5 vite: ^5.0.0 peerDependenciesMeta: @@ -414,20 +414,20 @@ packages: vite: optional: true - '@vitest/pretty-format@2.1.2': - resolution: {integrity: sha512-FIoglbHrSUlOJPDGIrh2bjX1sNars5HbxlcsFKCtKzu4+5lpsRhOCVcuzp0fEhAGHkPZRIXVNzPcpSlkoZ3LuA==} + '@vitest/pretty-format@2.1.3': + resolution: {integrity: sha512-XH1XdtoLZCpqV59KRbPrIhFCOO0hErxrQCMcvnQete3Vibb9UeIOX02uFPfVn3Z9ZXsq78etlfyhnkmIZSzIwQ==} - '@vitest/runner@2.1.2': - resolution: {integrity: sha512-UCsPtvluHO3u7jdoONGjOSil+uON5SSvU9buQh3lP7GgUXHp78guN1wRmZDX4wGK6J10f9NUtP6pO+SFquoMlw==} + '@vitest/runner@2.1.3': + resolution: {integrity: sha512-JGzpWqmFJ4fq5ZKHtVO3Xuy1iF2rHGV4d/pdzgkYHm1+gOzNZtqjvyiaDGJytRyMU54qkxpNzCx+PErzJ1/JqQ==} - '@vitest/snapshot@2.1.2': - resolution: {integrity: sha512-xtAeNsZ++aRIYIUsek7VHzry/9AcxeULlegBvsdLncLmNCR6tR8SRjn8BbDP4naxtccvzTqZ+L1ltZlRCfBZFA==} + '@vitest/snapshot@2.1.3': + resolution: {integrity: sha512-qWC2mWc7VAXmjAkEKxrScWHWFyCQx/cmiZtuGqMi+WwqQJ2iURsVY4ZfAK6dVo6K2smKRU6l3BPwqEBvhnpQGg==} - '@vitest/spy@2.1.2': - resolution: {integrity: sha512-GSUi5zoy+abNRJwmFhBDC0yRuVUn8WMlQscvnbbXdKLXX9dE59YbfwXxuJ/mth6eeqIzofU8BB5XDo/Ns/qK2A==} + '@vitest/spy@2.1.3': + resolution: {integrity: sha512-Nb2UzbcUswzeSP7JksMDaqsI43Sj5+Kry6ry6jQJT4b5gAK+NS9NED6mDb8FlMRCX8m5guaHCDZmqYMMWRy5nQ==} - '@vitest/utils@2.1.2': - resolution: {integrity: sha512-zMO2KdYy6mx56btx9JvAqAZ6EyS3g49krMPPrgOp1yxGZiA93HumGk+bZ5jIZtOg5/VBYl5eBmGRQHqq4FG6uQ==} + '@vitest/utils@2.1.3': + resolution: {integrity: sha512-xpiVfDSg1RrYT0tX6czgerkpcKFmFOF/gCr30+Mve5V2kewCy4Prn1/NDMSRwaSmT7PRaOF83wu+bEtsY1wrvA==} JSONStream@1.3.5: resolution: {integrity: sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==} @@ -631,8 +631,8 @@ packages: fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - fast-uri@3.0.2: - resolution: {integrity: sha512-GR6f0hD7XXyNJa25Tb9BuIdN0tdr+0BMi6/CJPH3wJO1JjNG3n/VsSw38AwRdKZABm8lGbPfakLRkYzx2V9row==} + fast-uri@3.0.3: + resolution: {integrity: sha512-aLrHthzCjH5He4Z2H9YZ+v6Ujb9ocRuW6ZzkJQOrTxleEijANq4v1TsaPaVG1PZcuurEzrLcWRyYBYXD5cEiaw==} fill-range@7.1.1: resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} @@ -881,8 +881,8 @@ packages: resolution: {integrity: sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==} engines: {node: '>= 14.16'} - picocolors@1.1.0: - resolution: {integrity: sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==} + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} @@ -1005,8 +1005,8 @@ packages: tinybench@2.9.0: resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} - tinyexec@0.3.0: - resolution: {integrity: sha512-tVGE0mVJPGb0chKhqmsoosjsS+qUnJVGJpZgsHYQcGoPlG3B51R3PouqTgEGH2Dc9jjFyOqOpix6ZHNMXp1FZg==} + tinyexec@0.3.1: + resolution: {integrity: sha512-WiCJLEECkO18gwqIp6+hJg0//p23HXp4S+gGtAKu3mI2F2/sXC4FvHvXvB0zJVVaTPhx1/tOwdbRsa1sOBIKqQ==} tinypool@1.0.1: resolution: {integrity: sha512-URZYihUbRPcGv95En+sz6MfghfIc2OJ1sv/RmhWZLouPY0/8Vo80viwPvg3dlaS9fuq7fQMEfgRRK7BBZThBEA==} @@ -1036,13 +1036,13 @@ packages: resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} engines: {node: '>=18'} - vite-node@2.1.2: - resolution: {integrity: sha512-HPcGNN5g/7I2OtPjLqgOtCRu/qhVvBxTUD3qzitmL0SrG1cWFzxzhMDWussxSbrRYWqnKf8P2jiNhPMSN+ymsQ==} + vite-node@2.1.3: + resolution: {integrity: sha512-I1JadzO+xYX887S39Do+paRePCKoiDrWRRjp9kkG5he0t7RXNvPAJPCQSJqbGN4uCrFFeS3Kj3sLqY8NMYBEdA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true - vite@5.4.8: - resolution: {integrity: sha512-FqrItQ4DT1NC4zCUqMB4c4AZORMKIa0m8/URVCZ77OZ/QSNeJ54bU1vrFADbDsuwfIPcgknRkmqakQcgnL4GiQ==} + vite@5.4.9: + resolution: {integrity: sha512-20OVpJHh0PAM0oSOELa5GaZNWeDjcAvQjGXy2Uyr+Tp+/D2/Hdz6NLgpJLsarPTA2QJ6v8mX2P1ZfbsSKvdMkg==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -1072,15 +1072,15 @@ packages: terser: optional: true - vitest@2.1.2: - resolution: {integrity: sha512-veNjLizOMkRrJ6xxb+pvxN6/QAWg95mzcRjtmkepXdN87FNfxAss9RKe2far/G9cQpipfgP2taqg0KiWsquj8A==} + vitest@2.1.3: + resolution: {integrity: sha512-Zrxbg/WiIvUP2uEzelDNTXmEMJXuzJ1kCpbDvaKByFA9MNeO95V+7r/3ti0qzJzrxdyuUw5VduN7k+D3VmVOSA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: '@edge-runtime/vm': '*' '@types/node': ^18.0.0 || >=20.0.0 - '@vitest/browser': 2.1.2 - '@vitest/ui': 2.1.2 + '@vitest/browser': 2.1.3 + '@vitest/ui': 2.1.3 happy-dom: '*' jsdom: '*' peerDependenciesMeta: @@ -1141,7 +1141,7 @@ snapshots: '@babel/code-frame@7.25.7': dependencies: '@babel/highlight': 7.25.7 - picocolors: 1.1.0 + picocolors: 1.1.1 '@babel/helper-validator-identifier@7.25.7': {} @@ -1150,7 +1150,7 @@ snapshots: '@babel/helper-validator-identifier': 7.25.7 chalk: 2.4.2 js-tokens: 4.0.0 - picocolors: 1.1.0 + picocolors: 1.1.1 '@biomejs/biome@1.9.3': optionalDependencies: @@ -1187,14 +1187,14 @@ snapshots: '@biomejs/cli-win32-x64@1.9.3': optional: true - '@commitlint/cli@19.5.0(@types/node@22.7.5)(typescript@5.6.3)': + '@commitlint/cli@19.5.0(@types/node@22.7.6)(typescript@5.6.3)': dependencies: '@commitlint/format': 19.5.0 '@commitlint/lint': 19.5.0 - '@commitlint/load': 19.5.0(@types/node@22.7.5)(typescript@5.6.3) + '@commitlint/load': 19.5.0(@types/node@22.7.6)(typescript@5.6.3) '@commitlint/read': 19.5.0 '@commitlint/types': 19.5.0 - tinyexec: 0.3.0 + tinyexec: 0.3.1 yargs: 17.7.2 transitivePeerDependencies: - '@types/node' @@ -1238,7 +1238,7 @@ snapshots: '@commitlint/rules': 19.5.0 '@commitlint/types': 19.5.0 - '@commitlint/load@19.5.0(@types/node@22.7.5)(typescript@5.6.3)': + '@commitlint/load@19.5.0(@types/node@22.7.6)(typescript@5.6.3)': dependencies: '@commitlint/config-validator': 19.5.0 '@commitlint/execute-rule': 19.5.0 @@ -1246,7 +1246,7 @@ snapshots: '@commitlint/types': 19.5.0 chalk: 5.3.0 cosmiconfig: 9.0.0(typescript@5.6.3) - cosmiconfig-typescript-loader: 5.0.0(@types/node@22.7.5)(cosmiconfig@9.0.0(typescript@5.6.3))(typescript@5.6.3) + cosmiconfig-typescript-loader: 5.0.0(@types/node@22.7.6)(cosmiconfig@9.0.0(typescript@5.6.3))(typescript@5.6.3) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -1268,7 +1268,7 @@ snapshots: '@commitlint/types': 19.5.0 git-raw-commits: 4.0.0 minimist: 1.2.8 - tinyexec: 0.3.0 + tinyexec: 0.3.1 '@commitlint/resolve-extends@19.5.0': dependencies: @@ -1418,51 +1418,51 @@ snapshots: '@types/conventional-commits-parser@5.0.0': dependencies: - '@types/node': 22.7.5 + '@types/node': 22.7.6 '@types/estree@1.0.6': {} - '@types/node@22.7.5': + '@types/node@22.7.6': dependencies: undici-types: 6.19.8 - '@vitest/expect@2.1.2': + '@vitest/expect@2.1.3': dependencies: - '@vitest/spy': 2.1.2 - '@vitest/utils': 2.1.2 + '@vitest/spy': 2.1.3 + '@vitest/utils': 2.1.3 chai: 5.1.1 tinyrainbow: 1.2.0 - '@vitest/mocker@2.1.2(@vitest/spy@2.1.2)(vite@5.4.8(@types/node@22.7.5))': + '@vitest/mocker@2.1.3(@vitest/spy@2.1.3)(vite@5.4.9(@types/node@22.7.6))': dependencies: - '@vitest/spy': 2.1.2 + '@vitest/spy': 2.1.3 estree-walker: 3.0.3 magic-string: 0.30.12 optionalDependencies: - vite: 5.4.8(@types/node@22.7.5) + vite: 5.4.9(@types/node@22.7.6) - '@vitest/pretty-format@2.1.2': + '@vitest/pretty-format@2.1.3': dependencies: tinyrainbow: 1.2.0 - '@vitest/runner@2.1.2': + '@vitest/runner@2.1.3': dependencies: - '@vitest/utils': 2.1.2 + '@vitest/utils': 2.1.3 pathe: 1.1.2 - '@vitest/snapshot@2.1.2': + '@vitest/snapshot@2.1.3': dependencies: - '@vitest/pretty-format': 2.1.2 + '@vitest/pretty-format': 2.1.3 magic-string: 0.30.12 pathe: 1.1.2 - '@vitest/spy@2.1.2': + '@vitest/spy@2.1.3': dependencies: tinyspy: 3.0.2 - '@vitest/utils@2.1.2': + '@vitest/utils@2.1.3': dependencies: - '@vitest/pretty-format': 2.1.2 + '@vitest/pretty-format': 2.1.3 loupe: 3.1.2 tinyrainbow: 1.2.0 @@ -1474,7 +1474,7 @@ snapshots: ajv@8.17.1: dependencies: fast-deep-equal: 3.1.3 - fast-uri: 3.0.2 + fast-uri: 3.0.3 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 @@ -1579,9 +1579,9 @@ snapshots: meow: 12.1.1 split2: 4.2.0 - cosmiconfig-typescript-loader@5.0.0(@types/node@22.7.5)(cosmiconfig@9.0.0(typescript@5.6.3))(typescript@5.6.3): + cosmiconfig-typescript-loader@5.0.0(@types/node@22.7.6)(cosmiconfig@9.0.0(typescript@5.6.3))(typescript@5.6.3): dependencies: - '@types/node': 22.7.5 + '@types/node': 22.7.6 cosmiconfig: 9.0.0(typescript@5.6.3) jiti: 1.21.6 typescript: 5.6.3 @@ -1675,7 +1675,7 @@ snapshots: fast-deep-equal@3.1.3: {} - fast-uri@3.0.2: {} + fast-uri@3.0.3: {} fill-range@7.1.1: dependencies: @@ -1881,7 +1881,7 @@ snapshots: pathval@2.0.0: {} - picocolors@1.1.0: {} + picocolors@1.1.1: {} picomatch@2.3.1: {} @@ -1890,7 +1890,7 @@ snapshots: postcss@8.4.47: dependencies: nanoid: 3.3.7 - picocolors: 1.1.0 + picocolors: 1.1.1 source-map-js: 1.2.1 require-directory@2.1.1: {} @@ -1994,7 +1994,7 @@ snapshots: tinybench@2.9.0: {} - tinyexec@0.3.0: {} + tinyexec@0.3.1: {} tinypool@1.0.1: {} @@ -2012,12 +2012,12 @@ snapshots: unicorn-magic@0.1.0: {} - vite-node@2.1.2(@types/node@22.7.5): + vite-node@2.1.3(@types/node@22.7.6): dependencies: cac: 6.7.14 debug: 4.3.7 pathe: 1.1.2 - vite: 5.4.8(@types/node@22.7.5) + vite: 5.4.9(@types/node@22.7.6) transitivePeerDependencies: - '@types/node' - less @@ -2029,38 +2029,38 @@ snapshots: - supports-color - terser - vite@5.4.8(@types/node@22.7.5): + vite@5.4.9(@types/node@22.7.6): dependencies: esbuild: 0.21.5 postcss: 8.4.47 rollup: 4.24.0 optionalDependencies: - '@types/node': 22.7.5 + '@types/node': 22.7.6 fsevents: 2.3.3 - vitest@2.1.2(@types/node@22.7.5): + vitest@2.1.3(@types/node@22.7.6): dependencies: - '@vitest/expect': 2.1.2 - '@vitest/mocker': 2.1.2(@vitest/spy@2.1.2)(vite@5.4.8(@types/node@22.7.5)) - '@vitest/pretty-format': 2.1.2 - '@vitest/runner': 2.1.2 - '@vitest/snapshot': 2.1.2 - '@vitest/spy': 2.1.2 - '@vitest/utils': 2.1.2 + '@vitest/expect': 2.1.3 + '@vitest/mocker': 2.1.3(@vitest/spy@2.1.3)(vite@5.4.9(@types/node@22.7.6)) + '@vitest/pretty-format': 2.1.3 + '@vitest/runner': 2.1.3 + '@vitest/snapshot': 2.1.3 + '@vitest/spy': 2.1.3 + '@vitest/utils': 2.1.3 chai: 5.1.1 debug: 4.3.7 magic-string: 0.30.12 pathe: 1.1.2 std-env: 3.7.0 tinybench: 2.9.0 - tinyexec: 0.3.0 + tinyexec: 0.3.1 tinypool: 1.0.1 tinyrainbow: 1.2.0 - vite: 5.4.8(@types/node@22.7.5) - vite-node: 2.1.2(@types/node@22.7.5) + vite: 5.4.9(@types/node@22.7.6) + vite-node: 2.1.3(@types/node@22.7.6) why-is-node-running: 2.3.0 optionalDependencies: - '@types/node': 22.7.5 + '@types/node': 22.7.6 transitivePeerDependencies: - less - lightningcss diff --git a/src/client/client.ts b/src/client/client.ts index 4a097f7..98ef161 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -5,11 +5,10 @@ import { type If, type WatcherPayload, type WatcherSendToShard, - hasIntent, lazyLoadPackage, } from '../common'; import { EventHandler } from '../events'; -import { type GatewayDispatchPayload, GatewayIntentBits, type GatewayPresenceUpdateData } from '../types'; +import type { GatewayDispatchPayload, GatewayPresenceUpdateData } from '../types'; import { ShardManager, type ShardManagerOptions, properties } from '../websocket'; import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate'; import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate'; @@ -191,7 +190,7 @@ export class Client extends BaseClient { this.botId = packet.d.user.id; this.applicationId = packet.d.application.id; this.me = Transformers.ClientUser(this, packet.d.user, packet.d.application) as never; - if (!hasIntent(this.gateway.options.intents, GatewayIntentBits.Guilds)) { + if (!this.__handleGuilds.length) { if ([...this.gateway.values()].every(shard => shard.data.session_id)) { await this.events?.runEvent('BOT_READY', this, this.me, -1); } diff --git a/src/client/workerclient.ts b/src/client/workerclient.ts index fec0153..6b4521e 100644 --- a/src/client/workerclient.ts +++ b/src/client/workerclient.ts @@ -1,9 +1,9 @@ import { type UUID, randomUUID } from 'node:crypto'; import { ApiHandler, Logger } from '..'; import { WorkerAdapter } from '../cache'; -import { type DeepPartial, LogLevels, type When, hasIntent, lazyLoadPackage } from '../common'; +import { type DeepPartial, LogLevels, type When, lazyLoadPackage } from '../common'; import { EventHandler } from '../events'; -import { type GatewayDispatchPayload, GatewayIntentBits, type GatewaySendPayload } from '../types'; +import type { GatewayDispatchPayload, GatewaySendPayload } from '../types'; import { Shard, type ShardManagerOptions, type WorkerData, properties } from '../websocket'; import type { WorkerDisconnectedAllShardsResharding, @@ -53,8 +53,8 @@ try { } export class WorkerClient extends BaseClient { - private __handleGuilds?: Set = new Set(); - private __handleGuildsResharding?: Set; + private __handleGuilds?: string[]; + private __handleGuildsResharding?: string[]; memberUpdateHandler = new MemberUpdateHandler(); presenceUpdateHandler = new PresenceUpdateHandler(); @@ -159,7 +159,7 @@ export class WorkerClient extends BaseClient { workerId: workerData.workerId, } satisfies WorkerStart | WorkerStartResharding); if (workerData.resharding) { - this.__handleGuildsResharding = new Set(); + this.__handleGuildsResharding = []; } await super.start(options); await this.loadEvents(options.eventsDir); @@ -253,25 +253,26 @@ export class WorkerClient extends BaseClient { }, handlePayload(_, payload) { if (payload.t === 'GUILD_CREATE' || payload.t === 'GUILD_DELETE') { - self.__handleGuildsResharding!.delete(payload.d.id); - if (!self.__handleGuildsResharding?.size && shardsConnected === workerData.shards.length) { - delete self.__handleGuildsResharding; - self.postMessage({ - type: 'WORKER_READY_RESHARDING', - workerId: workerData.workerId, - } satisfies WorkerReadyResharding); + const indexOf = self.__handleGuildsResharding!.indexOf(payload.d.id); + if (indexOf !== -1) { + self.__handleGuildsResharding!.splice(indexOf, 1); + if (!self.__handleGuildsResharding?.length && shardsConnected === workerData.shards.length) { + delete self.__handleGuildsResharding; + self.postMessage({ + type: 'WORKER_READY_RESHARDING', + workerId: workerData.workerId, + } satisfies WorkerReadyResharding); + } } } if (payload.t !== 'READY') return; shardsConnected++; - for (const guild of payload.d.guilds) { - self.__handleGuildsResharding!.add(guild.id); - } - if ( - shardsConnected === workerData.shards.length && - !hasIntent(workerData.intents, GatewayIntentBits.Guilds) - ) { + + const ids = payload.d.guilds.map(x => x.id); + self.__handleGuildsResharding = self.__handleGuildsResharding?.concat(ids) ?? ids; + + if (shardsConnected === workerData.shards.length && !self.__handleGuildsResharding.length) { delete self.__handleGuildsResharding; self.postMessage({ type: 'WORKER_READY_RESHARDING', @@ -399,7 +400,7 @@ export class WorkerClient extends BaseClient { break; case 'WORKER_ALREADY_EXISTS_RESHARDING': { - this.__handleGuildsResharding = new Set(); + this.__handleGuildsResharding = []; this.postMessage({ type: 'WORKER_START_RESHARDING', workerId: workerData.workerId, @@ -487,9 +488,9 @@ export class WorkerClient extends BaseClient { break; case 'GUILD_DELETE': case 'GUILD_CREATE': { - if (this.__handleGuilds?.has(packet.d.id)) { - this.__handleGuilds?.delete(packet.d.id); - if (!this.__handleGuilds?.size && [...this.shards.values()].every(shard => shard.data.session_id)) { + if (this.__handleGuilds?.includes(packet.d.id)) { + this.__handleGuilds?.splice(this.__handleGuilds!.indexOf(packet.d.id), 1); + if (!this.__handleGuilds?.length && [...this.shards.values()].every(shard => shard.data.session_id)) { delete this.__handleGuilds; await this.cache.onPacket(packet); this.postMessage({ @@ -498,7 +499,7 @@ export class WorkerClient extends BaseClient { } as WorkerReady); return this.events?.runEvent('WORKER_READY', this, this.me, -1); } - if (!this.__handleGuilds?.size) delete this.__handleGuilds; + if (!this.__handleGuilds?.length) delete this.__handleGuilds; return this.cache.onPacket(packet); } await this.events?.execute(packet.t, packet, this, shardId); @@ -520,10 +521,8 @@ export class WorkerClient extends BaseClient { break; case 'READY': { - if (!this.__handleGuilds) this.__handleGuilds = new Set(); - for (const g of packet.d.guilds) { - this.__handleGuilds?.add(g.id); - } + const ids = packet.d.guilds.map(x => x.id); + this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids; this.botId = packet.d.user.id; this.applicationId = packet.d.application.id; this.me = Transformers.ClientUser(this, packet.d.user, packet.d.application) as never; @@ -536,7 +535,7 @@ export class WorkerClient extends BaseClient { } as WorkerShardsConnected); await this.events?.runEvent('WORKER_SHARDS_CONNECTED', this, this.me, -1); } - if (!hasIntent(workerData.intents, GatewayIntentBits.Guilds)) { + if (!this.__handleGuilds.length) { if ([...this.shards.values()].every(shard => shard.data.session_id)) { this.postMessage({ type: 'WORKER_READY',