mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
feat(ShardingManager): add options typings (#5583)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
@@ -19,23 +19,28 @@ const Util = require('../util/Util');
|
|||||||
*/
|
*/
|
||||||
class ShardingManager extends EventEmitter {
|
class ShardingManager extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* The mode to spawn shards with for a {@link ShardingManager}: either "process" to use child processes, or
|
* The mode to spawn shards with for a {@link ShardingManager}. Either "process" to use child processes, or
|
||||||
* "worker" to use [Worker threads](https://nodejs.org/api/worker_threads.html).
|
* "worker" to use [Worker threads](https://nodejs.org/api/worker_threads.html).
|
||||||
* @typedef {Object} ShardingManagerMode
|
* @typedef {string} ShardingManagerMode
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The options to spawn shards with for a {@link ShardingManager},
|
||||||
|
* @typedef {Object} ShardingManagerOptions
|
||||||
|
* @property {string|number} [totalShards='auto'] Number of total shards of all shard managers or "auto"
|
||||||
|
* @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 {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
|
||||||
|
* (only available when mode is set to 'process')
|
||||||
|
* @property {string} [token] Token to use for automatic shard count and passing to shards
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} file Path to your shard script file
|
* @param {string} file Path to your shard script file
|
||||||
* @param {Object} [options] Options for the sharding manager
|
* @param {ShardingManagerOptions} [options] Options for the sharding manager
|
||||||
* @param {string|number} [options.totalShards='auto'] Number of total shards of all shard managers or "auto"
|
|
||||||
* @param {string|number[]} [options.shardList='auto'] List of shards to spawn or "auto"
|
|
||||||
* @param {ShardingManagerMode} [options.mode='process'] Which mode to use for shards
|
|
||||||
* @param {boolean} [options.respawn=true] Whether shards should automatically respawn upon exiting
|
|
||||||
* @param {string[]} [options.shardArgs=[]] Arguments to pass to the shard script when spawning
|
|
||||||
* (only available when using the `process` mode)
|
|
||||||
* @param {string[]} [options.execArgv=[]] Arguments to pass to the shard script executable when spawning
|
|
||||||
* (only available when using the `process` mode)
|
|
||||||
* @param {string} [options.token] Token to use for automatic shard count and passing to shards
|
|
||||||
*/
|
*/
|
||||||
constructor(file, options = {}) {
|
constructor(file, options = {}) {
|
||||||
super();
|
super();
|
||||||
|
|||||||
23
typings/index.d.ts
vendored
23
typings/index.d.ts
vendored
@@ -1516,18 +1516,7 @@ declare module 'discord.js' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ShardingManager extends EventEmitter {
|
export class ShardingManager extends EventEmitter {
|
||||||
constructor(
|
constructor(file: string, options?: ShardingManagerOptions);
|
||||||
file: string,
|
|
||||||
options?: {
|
|
||||||
totalShards?: number | 'auto';
|
|
||||||
shardList?: number[] | 'auto';
|
|
||||||
mode?: ShardingManagerMode;
|
|
||||||
respawn?: boolean;
|
|
||||||
shardArgs?: string[];
|
|
||||||
token?: string;
|
|
||||||
execArgv?: string[];
|
|
||||||
},
|
|
||||||
);
|
|
||||||
private _performOnShards(method: string, args: any[]): Promise<any[]>;
|
private _performOnShards(method: string, args: any[]): Promise<any[]>;
|
||||||
private _performOnShards(method: string, args: any[], shard: number): Promise<any>;
|
private _performOnShards(method: string, args: any[], shard: number): Promise<any>;
|
||||||
|
|
||||||
@@ -3510,6 +3499,16 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
type ShardingManagerMode = 'process' | 'worker';
|
type ShardingManagerMode = 'process' | 'worker';
|
||||||
|
|
||||||
|
interface ShardingManagerOptions {
|
||||||
|
totalShards?: number | 'auto';
|
||||||
|
shardList?: number[] | 'auto';
|
||||||
|
mode?: ShardingManagerMode;
|
||||||
|
respawn?: boolean;
|
||||||
|
shardArgs?: string[];
|
||||||
|
token?: string;
|
||||||
|
execArgv?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
type Snowflake = string;
|
type Snowflake = string;
|
||||||
|
|
||||||
interface SplitOptions {
|
interface SplitOptions {
|
||||||
|
|||||||
Reference in New Issue
Block a user