seyfert 2.1.1-dev-11319654918.0 → 2.1.1-dev-11388830407.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import type { CommandContext, Message } from '..';
2
2
  import { type Awaitable, type DeepPartial, type If } from '../common';
3
3
  import { EventHandler } from '../events';
4
- import { type GatewayDispatchPayload, type GatewayPresenceUpdateData } from '../types';
4
+ import type { GatewayDispatchPayload, GatewayPresenceUpdateData } from '../types';
5
5
  import { ShardManager, type ShardManagerOptions } from '../websocket';
6
6
  import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
7
7
  import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Client = void 0;
4
4
  const common_1 = require("../common");
5
5
  const events_1 = require("../events");
6
- const types_1 = require("../types");
7
6
  const websocket_1 = require("../websocket");
8
7
  const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
9
8
  const presenceUpdate_1 = require("../websocket/discord/events/presenceUpdate");
@@ -164,7 +163,7 @@ class Client extends base_1.BaseClient {
164
163
  this.botId = packet.d.user.id;
165
164
  this.applicationId = packet.d.application.id;
166
165
  this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
167
- if (!(0, common_1.hasIntent)(this.gateway.options.intents, types_1.GatewayIntentBits.Guilds)) {
166
+ if (!this.__handleGuilds.length) {
168
167
  if ([...this.gateway.values()].every(shard => shard.data.session_id)) {
169
168
  await this.events?.runEvent('BOT_READY', this, this.me, -1);
170
169
  }
@@ -1,6 +1,6 @@
1
1
  import { type DeepPartial, type When } from '../common';
2
2
  import { EventHandler } from '../events';
3
- import { type GatewayDispatchPayload } from '../types';
3
+ import type { GatewayDispatchPayload } from '../types';
4
4
  import { Shard, type ShardManagerOptions, type WorkerData } from '../websocket';
5
5
  import type { WorkerMessage, WorkerShardInfo } from '../websocket/discord/worker';
6
6
  import type { ManagerMessages } from '../websocket/discord/workermanager';
@@ -7,7 +7,6 @@ const __1 = require("..");
7
7
  const cache_1 = require("../cache");
8
8
  const common_1 = require("../common");
9
9
  const events_1 = require("../events");
10
- const types_1 = require("../types");
11
10
  const websocket_1 = require("../websocket");
12
11
  const base_1 = require("./base");
13
12
  const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
@@ -34,7 +33,7 @@ catch {
34
33
  //
35
34
  }
36
35
  class WorkerClient extends base_1.BaseClient {
37
- __handleGuilds = new Set();
36
+ __handleGuilds;
38
37
  __handleGuildsResharding;
39
38
  memberUpdateHandler = new memberUpdate_1.MemberUpdateHandler();
40
39
  presenceUpdateHandler = new presenceUpdate_1.PresenceUpdateHandler();
@@ -122,7 +121,7 @@ class WorkerClient extends base_1.BaseClient {
122
121
  workerId: workerData.workerId,
123
122
  });
124
123
  if (workerData.resharding) {
125
- this.__handleGuildsResharding = new Set();
124
+ this.__handleGuildsResharding = [];
126
125
  }
127
126
  await super.start(options);
128
127
  await this.loadEvents(options.eventsDir);
@@ -211,23 +210,24 @@ class WorkerClient extends base_1.BaseClient {
211
210
  },
212
211
  handlePayload(_, payload) {
213
212
  if (payload.t === 'GUILD_CREATE' || payload.t === 'GUILD_DELETE') {
214
- self.__handleGuildsResharding.delete(payload.d.id);
215
- if (!self.__handleGuildsResharding?.size && shardsConnected === workerData.shards.length) {
216
- delete self.__handleGuildsResharding;
217
- self.postMessage({
218
- type: 'WORKER_READY_RESHARDING',
219
- workerId: workerData.workerId,
220
- });
213
+ const indexOf = self.__handleGuildsResharding.indexOf(payload.d.id);
214
+ if (indexOf !== -1) {
215
+ self.__handleGuildsResharding.splice(indexOf, 1);
216
+ if (!self.__handleGuildsResharding?.length && shardsConnected === workerData.shards.length) {
217
+ delete self.__handleGuildsResharding;
218
+ self.postMessage({
219
+ type: 'WORKER_READY_RESHARDING',
220
+ workerId: workerData.workerId,
221
+ });
222
+ }
221
223
  }
222
224
  }
223
225
  if (payload.t !== 'READY')
224
226
  return;
225
227
  shardsConnected++;
226
- for (const guild of payload.d.guilds) {
227
- self.__handleGuildsResharding.add(guild.id);
228
- }
229
- if (shardsConnected === workerData.shards.length &&
230
- !(0, common_1.hasIntent)(workerData.intents, types_1.GatewayIntentBits.Guilds)) {
228
+ const ids = payload.d.guilds.map(x => x.id);
229
+ self.__handleGuildsResharding = self.__handleGuildsResharding?.concat(ids) ?? ids;
230
+ if (shardsConnected === workerData.shards.length && !self.__handleGuildsResharding.length) {
231
231
  delete self.__handleGuildsResharding;
232
232
  self.postMessage({
233
233
  type: 'WORKER_READY_RESHARDING',
@@ -357,7 +357,7 @@ class WorkerClient extends base_1.BaseClient {
357
357
  break;
358
358
  case 'WORKER_ALREADY_EXISTS_RESHARDING':
359
359
  {
360
- this.__handleGuildsResharding = new Set();
360
+ this.__handleGuildsResharding = [];
361
361
  this.postMessage({
362
362
  type: 'WORKER_START_RESHARDING',
363
363
  workerId: workerData.workerId,
@@ -442,9 +442,9 @@ class WorkerClient extends base_1.BaseClient {
442
442
  break;
443
443
  case 'GUILD_DELETE':
444
444
  case 'GUILD_CREATE': {
445
- if (this.__handleGuilds?.has(packet.d.id)) {
446
- this.__handleGuilds?.delete(packet.d.id);
447
- if (!this.__handleGuilds?.size && [...this.shards.values()].every(shard => shard.data.session_id)) {
445
+ if (this.__handleGuilds?.includes(packet.d.id)) {
446
+ this.__handleGuilds?.splice(this.__handleGuilds.indexOf(packet.d.id), 1);
447
+ if (!this.__handleGuilds?.length && [...this.shards.values()].every(shard => shard.data.session_id)) {
448
448
  delete this.__handleGuilds;
449
449
  await this.cache.onPacket(packet);
450
450
  this.postMessage({
@@ -453,7 +453,7 @@ class WorkerClient extends base_1.BaseClient {
453
453
  });
454
454
  return this.events?.runEvent('WORKER_READY', this, this.me, -1);
455
455
  }
456
- if (!this.__handleGuilds?.size)
456
+ if (!this.__handleGuilds?.length)
457
457
  delete this.__handleGuilds;
458
458
  return this.cache.onPacket(packet);
459
459
  }
@@ -476,11 +476,8 @@ class WorkerClient extends base_1.BaseClient {
476
476
  break;
477
477
  case 'READY':
478
478
  {
479
- if (!this.__handleGuilds)
480
- this.__handleGuilds = new Set();
481
- for (const g of packet.d.guilds) {
482
- this.__handleGuilds?.add(g.id);
483
- }
479
+ const ids = packet.d.guilds.map(x => x.id);
480
+ this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids;
484
481
  this.botId = packet.d.user.id;
485
482
  this.applicationId = packet.d.application.id;
486
483
  this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
@@ -493,7 +490,7 @@ class WorkerClient extends base_1.BaseClient {
493
490
  });
494
491
  await this.events?.runEvent('WORKER_SHARDS_CONNECTED', this, this.me, -1);
495
492
  }
496
- if (!(0, common_1.hasIntent)(workerData.intents, types_1.GatewayIntentBits.Guilds)) {
493
+ if (!this.__handleGuilds.length) {
497
494
  if ([...this.shards.values()].every(shard => shard.data.session_id)) {
498
495
  this.postMessage({
499
496
  type: 'WORKER_READY',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seyfert",
3
- "version": "2.1.1-dev-11319654918.0",
3
+ "version": "2.1.1-dev-11388830407.0",
4
4
  "description": "The most advanced framework for discord bots",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -24,11 +24,11 @@
24
24
  "@biomejs/biome": "1.9.3",
25
25
  "@commitlint/cli": "^19.5.0",
26
26
  "@commitlint/config-conventional": "^19.5.0",
27
- "@types/node": "^22.7.5",
27
+ "@types/node": "^22.7.6",
28
28
  "husky": "^9.1.6",
29
29
  "lint-staged": "^15.2.10",
30
30
  "typescript": "^5.6.3",
31
- "vitest": "^2.1.2"
31
+ "vitest": "^2.1.3"
32
32
  },
33
33
  "homepage": "https://seyfert.dev",
34
34
  "repository": {