From 9446a4dc894c1775a83be4b93dfd8d02524539e5 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sun, 10 Dec 2023 22:47:11 +0200 Subject: [PATCH] allow shards to spawn one at a time --- @types/Moderation.d.ts | 2 +- src/client/components/ModerationManager.ts | 2 +- src/middleware/Controller.ts | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/@types/Moderation.d.ts b/@types/Moderation.d.ts index 2bc0cb8..9d11716 100644 --- a/@types/Moderation.d.ts +++ b/@types/Moderation.d.ts @@ -1,4 +1,4 @@ -import { GuildBasedChannel, Message } from 'discord.js'; +import { GuildBasedChannel, GuildTextBasedChannel, Message } from 'discord.js'; import { GuildWrapper, InvokerWrapper, MemberWrapper, UserWrapper } from '../src/client/components/wrappers/index.ts'; import { CommandOption, Infraction } from '../src/client/interfaces/index.ts'; import { FormatParams, InfractionType } from './Client.ts'; diff --git a/src/client/components/ModerationManager.ts b/src/client/components/ModerationManager.ts index 088e9b2..d6c4c14 100644 --- a/src/client/components/ModerationManager.ts +++ b/src/client/components/ModerationManager.ts @@ -182,7 +182,7 @@ class ModerationManager implements Initialisable const response = await this._handleTarget(Infraction, target, { invoker, guild: invoker.guild!, - channel: invoker.channel, + channel: invoker.channel as GuildTextBasedChannel, executor, arguments: args, points: args.points?.asNumber, diff --git a/src/middleware/Controller.ts b/src/middleware/Controller.ts index fd46b08..33b0268 100644 --- a/src/middleware/Controller.ts +++ b/src/middleware/Controller.ts @@ -133,14 +133,15 @@ class Controller extends EventEmitter throw new TypeError('Amount of shards must be an integer.'); } - const promises = []; + // const promises = []; for (let i = 0; i < shardCount; i++) { const shard = this.createShard(shardCount); - promises.push(shard.spawn()); + await shard.spawn(90_000); + // promises.push(); } - await Promise.all(promises); + // await Promise.all(promises); this.#logger.status(`Shards spawned, spawned ${this.#shards.size} shards. Took ${Date.now() - start} ms`);