diff --git a/@types/Shared.d.ts b/@types/Shared.d.ts index 742bd9b..e817dd5 100644 --- a/@types/Shared.d.ts +++ b/@types/Shared.d.ts @@ -6,7 +6,6 @@ export type PlainError = { export type EnvObject = { [key: string]: unknown, - SHARDING_MANAGER: boolean, SHARD_ID: number, SHARD_COUNT: number, } diff --git a/src/middleware/Shard.ts b/src/middleware/Shard.ts index a827f4c..2c39fb6 100644 --- a/src/middleware/Shard.ts +++ b/src/middleware/Shard.ts @@ -2,22 +2,24 @@ import EventEmitter from 'node:events'; import path from 'node:path'; import childProcess, { ChildProcess } from 'node:child_process'; -import { EnvObject, IPCMessage, PlainError } from '../../@types/Shared.js'; import Controller from './Controller.js'; +import Util from '../utilities/Util.js'; + import { ShardOptions } from '../../@types/Shard.js'; import { ClientOptions } from '../../@types/Client.js'; -import Util from '../utilities/Util.js'; +import { EnvObject, IPCMessage, PlainError } from '../../@types/Shared.js'; + const KillTO = 90 * 1000; class Shard extends EventEmitter { [key: string]: unknown; - #debug: boolean; #id: number; #controller: Controller; - #env: EnvObject; // { [key: string]: string | boolean | number }; + #env: EnvObject; #ready: boolean; + #debug: boolean; #clientOptions: ClientOptions; #args: string[]; @@ -50,20 +52,14 @@ class Shard extends EventEmitter throw new Error('Missing file'); this.#file = options.file; this.#respawn = options.respawn ?? true; - if (!options.token) - throw new Error('Missing token'); this.#env = { ...process.env, - SHARDING_MANAGER: true, // IMPORTANT, SHARD IPC WILL BREAK IF MISSING - SHARDING_MANAGER_MODE: 'process', // IMPORTANT, SHARD IPC WILL BREAK IF MISSING SHARDS: this.#id, SHARD_ID: this.#id, SHARD_COUNT: options.totalShards, - DISCORD_TOKEN: options.token }; - if (!options.clientOptions?.libraryOptions) - throw new Error('Missing library options, must provide intents'); + this.#clientOptions = options.clientOptions || {}; this.#ready = false;