mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
refactor(*): make typedefs for all options params (#5785)
Co-authored-by: Rodry <38259440+ImRodry@users.noreply.github.com> Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
This commit is contained in:
@@ -103,7 +103,7 @@ class Shard extends EventEmitter {
|
||||
* Forks a child process or creates a worker thread for the shard.
|
||||
* <warn>You should not need to call this manually.</warn>
|
||||
* @param {number} [timeout=30000] The amount in milliseconds to wait until the {@link Client} has become ready
|
||||
* before resolving. (-1 or Infinity for no wait)
|
||||
* before resolving (`-1` or `Infinity` for no wait)
|
||||
* @returns {Promise<ChildProcess>}
|
||||
*/
|
||||
async spawn(timeout = 30000) {
|
||||
@@ -187,13 +187,17 @@ class Shard extends EventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Kills and restarts the shard's process/worker.
|
||||
* @param {Object} [options] Respawn options for the shard
|
||||
* @param {number} [options.delay=500] How long to wait between killing the process/worker and
|
||||
* Options used to respawn a shard.
|
||||
* @typedef {Object} ShardRespawnOptions
|
||||
* @property {number} [delay=500] How long to wait between killing the process/worker and
|
||||
* restarting it (in milliseconds)
|
||||
* @param {number} [options.timeout=30000] The amount in milliseconds to wait until the {@link Client}
|
||||
* has become ready
|
||||
* before resolving. (-1 or Infinity for no wait)
|
||||
* @property {number} [timeout=30000] The amount in milliseconds to wait until the {@link Client}
|
||||
* has become ready before resolving (`-1` or `Infinity` for no wait)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Kills and restarts the shard's process/worker.
|
||||
* @param {ShardRespawnOptions} [options] Options for respawning the shard
|
||||
* @returns {Promise<ChildProcess>}
|
||||
*/
|
||||
async respawn({ delay = 500, timeout = 30000 } = {}) {
|
||||
|
||||
@@ -163,12 +163,7 @@ class ShardClientUtil {
|
||||
|
||||
/**
|
||||
* Requests a respawn of all shards.
|
||||
* @param {Object} [options] Options for respawning shards
|
||||
* @param {number} [options.shardDelay=5000] How long to wait between shards (in milliseconds)
|
||||
* @param {number} [options.respawnDelay=500] How long to wait between killing a shard's process/worker and
|
||||
* restarting it (in milliseconds)
|
||||
* @param {number} [options.timeout=30000] The amount in milliseconds to wait for a shard to become ready before
|
||||
* continuing to another. (-1 or Infinity for no wait)
|
||||
* @param {MultipleShardRespawnOptions} [options] Options for respawning shards
|
||||
* @returns {Promise<void>} Resolves upon the message being sent
|
||||
* @see {@link ShardingManager#respawnAll}
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ class ShardingManager extends EventEmitter {
|
||||
*/
|
||||
|
||||
/**
|
||||
* The options to spawn shards with for a {@link ShardingManager},
|
||||
* 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"
|
||||
@@ -164,12 +164,17 @@ class ShardingManager extends EventEmitter {
|
||||
return shard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Option used to spawn multiple shards.
|
||||
* @typedef {Object} MultipleShardSpawnOptions
|
||||
* @property {number|string} [amount=this.totalShards] Number of shards to spawn
|
||||
* @property {number} [delay=5500] How long to wait in between spawning each shard (in milliseconds)
|
||||
* @property {number} [timeout=30000] The amount in milliseconds to wait until the {@link Client} has become ready
|
||||
*/
|
||||
|
||||
/**
|
||||
* Spawns multiple shards.
|
||||
* @param {Object} [options] Options for spawning shards
|
||||
* @param {number|string} [options.amount=this.totalShards] Number of shards to spawn
|
||||
* @param {number} [options.delay=5500] How long to wait in between spawning each shard (in milliseconds)
|
||||
* @param {number} [options.timeout=30000] The amount in milliseconds to wait until the {@link Client} has become
|
||||
* @param {MultipleShardSpawnOptions} [options] Options for spawning shards
|
||||
* @returns {Promise<Collection<number, Shard>>}
|
||||
*/
|
||||
async spawn({ amount = this.totalShards, delay = 5500, timeout = 30000 } = {}) {
|
||||
@@ -282,13 +287,18 @@ class ShardingManager extends EventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Kills all running shards and respawns them.
|
||||
* @param {Object} [options] Options for respawning shards
|
||||
* @param {number} [options.shardDelay=5000] How long to wait between shards (in milliseconds)
|
||||
* @param {number} [options.respawnDelay=500] How long to wait between killing a shard's process and restarting it
|
||||
* Options used to respawn all shards.
|
||||
* @typedef {Object} MultipleShardRespawnOptions
|
||||
* @property {number} [shardDelay=5000] How long to wait between shards (in milliseconds)
|
||||
* @property {number} [respawnDelay=500] How long to wait between killing a shard's process and restarting it
|
||||
* (in milliseconds)
|
||||
* @param {number} [options.timeout=30000] The amount in milliseconds to wait for a shard to become ready before
|
||||
* continuing to another. (-1 or Infinity for no wait)
|
||||
* @property {number} [timeout=30000] The amount in milliseconds to wait for a shard to become ready before
|
||||
* continuing to another (`-1` or `Infinity` for no wait)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Kills all running shards and respawns them.
|
||||
* @param {MultipleShardRespawnOptions} [options] Options for respawning shards
|
||||
* @returns {Promise<Collection<string, Shard>>}
|
||||
*/
|
||||
async respawnAll({ shardDelay = 5000, respawnDelay = 500, timeout = 30000 } = {}) {
|
||||
|
||||
Reference in New Issue
Block a user