seyfert 2.1.1-dev-12309470171.0 → 2.1.1-dev-12325972671.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.
@@ -23,6 +23,7 @@ export declare class Client<Ready extends boolean = boolean> extends BaseClient
23
23
  setServices({ gateway, ...rest }: ServicesOptions & {
24
24
  gateway?: ShardManager;
25
25
  }): void;
26
+ get latency(): number;
26
27
  loadEvents(dir?: string): Promise<void>;
27
28
  protected execute(options?: {
28
29
  token?: string;
@@ -32,8 +32,13 @@ class Client extends base_1.BaseClient {
32
32
  this.gateway = gateway;
33
33
  }
34
34
  }
35
+ get latency() {
36
+ let acc = 0;
37
+ this.gateway.forEach(s => (acc += s.latency));
38
+ return acc / this.gateway.size;
39
+ }
35
40
  async loadEvents(dir) {
36
- dir ??= await this.getRC().then(x => ('events' in x.locations ? x.locations.events : undefined));
41
+ dir ??= await this.getRC().then(x => x.locations.events);
37
42
  if (dir) {
38
43
  await this.events.load(dir);
39
44
  this.logger.info('EventHandler loaded');
@@ -193,10 +193,9 @@ class WorkerClient extends base_1.BaseClient {
193
193
  ...this.options.gateway?.properties,
194
194
  },
195
195
  handlePayload(_, payload) {
196
- if (payload.t === 'READY') {
197
- shardsConnected++;
198
- }
199
- else if (payload.t === 'GUILDS_READY' && shardsConnected === workerData.shards.length) {
196
+ if (payload.t !== 'GUILDS_READY')
197
+ return;
198
+ if (++shardsConnected === workerData.shards.length) {
200
199
  self.postMessage({
201
200
  type: 'WORKER_READY_RESHARDING',
202
201
  workerId: workerData.workerId,
@@ -105,31 +105,21 @@ class ShardManager extends Map {
105
105
  this.options.info.session_start_limit.max_concurrency = info.session_start_limit.max_concurrency;
106
106
  //waiting for all shards to connect
107
107
  let shardsConnected = 0;
108
- const handleGuilds = new Set();
109
- let handlePayload = async (sharder, _, packet) => {
110
- if (packet.t === 'GUILD_CREATE' || packet.t === 'GUILD_DELETE') {
111
- handleGuilds.delete(packet.d.id);
112
- if (shardsConnected === info.shards && !handleGuilds.size) {
113
- return cleanProcess(sharder);
114
- }
115
- }
116
- if (packet.t !== 'READY')
108
+ let handlePayload = (sharder, _, packet) => {
109
+ if (packet.t !== 'GUILDS_READY')
117
110
  return;
118
- for (const guild of packet.d.guilds) {
119
- handleGuilds.add(guild.id);
120
- }
121
- if (++shardsConnected < info.shards || handleGuilds.size)
111
+ if (++shardsConnected !== info.shards)
122
112
  return;
123
113
  cleanProcess(sharder);
124
114
  // dont listen more events when all shards are ready
125
115
  };
126
116
  const cleanProcess = (sharder) => {
127
- handlePayload = async () => {
117
+ handlePayload = () => {
128
118
  //
129
119
  };
130
120
  this.disconnectAll();
131
121
  this.clear();
132
- this.options.totalShards = this.options.shardEnd = info.shards;
122
+ this.options.totalShards = this.options.shardEnd = this.options.info.shards = info.shards;
133
123
  for (const [id, shard] of sharder) {
134
124
  shard.options.handlePayload = (shardId, packet) => {
135
125
  return this.options.handlePayload(shardId, packet);
@@ -234,7 +234,7 @@ class WorkerManager extends Map {
234
234
  this.get(message.workerId).disconnected = true;
235
235
  if ([...this.values()].every(w => w.disconnected)) {
236
236
  this.options.totalShards = this._info.shards;
237
- this.options.shardEnd = this.options.totalShards = this._info.shards;
237
+ this.options.shardEnd = this.options.totalShards = this.options.info.shards = this._info.shards;
238
238
  this.options.workers = this.size;
239
239
  delete this._info;
240
240
  for (const [id] of this.entries()) {
@@ -538,7 +538,7 @@ class WorkerManager extends Map {
538
538
  shardEnd: info.shards,
539
539
  shardStart: 0,
540
540
  }, this.debugger);
541
- await this.prepareWorkers(spaces, true);
541
+ this.prepareWorkers(spaces, true);
542
542
  return this.reshardingWorkerQueue.shift()();
543
543
  }, this.options.resharding.interval);
544
544
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seyfert",
3
- "version": "2.1.1-dev-12309470171.0",
3
+ "version": "2.1.1-dev-12325972671.0",
4
4
  "description": "The most advanced framework for discord bots",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",