mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat: add silent option to ShardingManager (#9506)
* feat: add silent option to ShardingManager * chore: update ShardingManagerOptions type * chore: update typings --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -42,6 +42,12 @@ class Shard extends EventEmitter {
|
||||
*/
|
||||
this.id = id;
|
||||
|
||||
/**
|
||||
* Whether to pass silent flag to the shard's process (only when {@link ShardingManager#mode} is `process`)
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.silent = manager.silent;
|
||||
|
||||
/**
|
||||
* Arguments for the shard's process (only when {@link ShardingManager#mode} is `process`)
|
||||
* @type {string[]}
|
||||
@@ -124,6 +130,7 @@ class Shard extends EventEmitter {
|
||||
.fork(path.resolve(this.manager.file), this.args, {
|
||||
env: this.env,
|
||||
execArgv: this.execArgv,
|
||||
silent: this.silent,
|
||||
})
|
||||
.on('message', this._handleMessage.bind(this))
|
||||
.on('exit', this._exitListener);
|
||||
|
||||
@@ -34,6 +34,8 @@ class ShardingManager extends EventEmitter {
|
||||
* @property {string|number[]} [shardList='auto'] List of shards to spawn or "auto"
|
||||
* @property {ShardingManagerMode} [mode='process'] Which mode to use for shards
|
||||
* @property {boolean} [respawn=true] Whether shards should automatically respawn upon exiting
|
||||
* @property {boolean} [silent=false] Whether to pass the silent flag to child process
|
||||
* (only available when mode is set to 'process')
|
||||
* @property {string[]} [shardArgs=[]] Arguments to pass to the shard script when spawning
|
||||
* (only available when mode is set to 'process')
|
||||
* @property {string[]} [execArgv=[]] Arguments to pass to the shard script executable when spawning
|
||||
@@ -52,6 +54,7 @@ class ShardingManager extends EventEmitter {
|
||||
totalShards: 'auto',
|
||||
mode: 'process',
|
||||
respawn: true,
|
||||
silent: false,
|
||||
shardArgs: [],
|
||||
execArgv: [],
|
||||
token: process.env.DISCORD_TOKEN,
|
||||
@@ -123,6 +126,12 @@ class ShardingManager extends EventEmitter {
|
||||
*/
|
||||
this.respawn = options.respawn;
|
||||
|
||||
/**
|
||||
* Whether to pass the silent flag to child process (only when {@link ShardingManager#mode} is `process`)
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.silent = options.silent;
|
||||
|
||||
/**
|
||||
* An array of arguments to pass to shards (only when {@link ShardingManager#mode} is `process`)
|
||||
* @type {string[]}
|
||||
|
||||
3
packages/discord.js/typings/index.d.ts
vendored
3
packages/discord.js/typings/index.d.ts
vendored
@@ -2696,6 +2696,7 @@ export class Shard extends EventEmitter {
|
||||
public manager: ShardingManager;
|
||||
public process: ChildProcess | null;
|
||||
public ready: boolean;
|
||||
public silent: boolean;
|
||||
public worker: Worker | null;
|
||||
public eval(script: string): Promise<unknown>;
|
||||
public eval<T>(fn: (client: Client) => T): Promise<T>;
|
||||
@@ -2755,6 +2756,7 @@ export class ShardingManager extends EventEmitter {
|
||||
|
||||
public file: string;
|
||||
public respawn: boolean;
|
||||
public silent: boolean;
|
||||
public shardArgs: string[];
|
||||
public shards: Collection<number, Shard>;
|
||||
public token: string | null;
|
||||
@@ -6183,6 +6185,7 @@ export interface ShardingManagerOptions {
|
||||
shardList?: number[] | 'auto';
|
||||
mode?: ShardingManagerMode;
|
||||
respawn?: boolean;
|
||||
silent?: boolean;
|
||||
shardArgs?: string[];
|
||||
token?: string;
|
||||
execArgv?: string[];
|
||||
|
||||
Reference in New Issue
Block a user