refactor: ES2021 features (#6540)

Co-authored-by: Antonio Román <kyradiscord@gmail.com>
Co-authored-by: Voltrex <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
Rodry
2021-09-03 12:58:01 +01:00
committed by GitHub
parent d81590d566
commit 00bd92a451
35 changed files with 145 additions and 156 deletions

View File

@@ -106,7 +106,7 @@ class Shard extends EventEmitter {
* before resolving (`-1` or `Infinity` for no wait)
* @returns {Promise<ChildProcess>}
*/
spawn(timeout = 30000) {
spawn(timeout = 30_000) {
if (this.process) throw new Error('SHARDING_PROCESS_EXISTS', this.id);
if (this.worker) throw new Error('SHARDING_WORKER_EXISTS', this.id);
@@ -201,7 +201,7 @@ class Shard extends EventEmitter {
* @param {ShardRespawnOptions} [options] Options for respawning the shard
* @returns {Promise<ChildProcess>}
*/
async respawn({ delay = 500, timeout = 30000 } = {}) {
async respawn({ delay = 500, timeout = 30_000 } = {}) {
this.kill();
if (delay > 0) await Util.delayFor(delay);
return this.spawn(timeout);

View File

@@ -167,7 +167,7 @@ class ShardClientUtil {
* @returns {Promise<void>} Resolves upon the message being sent
* @see {@link ShardingManager#respawnAll}
*/
respawnAll({ shardDelay = 5000, respawnDelay = 500, timeout = 30000 } = {}) {
respawnAll({ shardDelay = 5_000, respawnDelay = 500, timeout = 30_000 } = {}) {
return this.send({ _sRespawnAll: { shardDelay, respawnDelay, timeout } });
}

View File

@@ -178,7 +178,7 @@ class ShardingManager extends EventEmitter {
* @param {MultipleShardSpawnOptions} [options] Options for spawning shards
* @returns {Promise<Collection<number, Shard>>}
*/
async spawn({ amount = this.totalShards, delay = 5500, timeout = 30000 } = {}) {
async spawn({ amount = this.totalShards, delay = 5500, timeout = 30_000 } = {}) {
// Obtain/verify the number of shards to spawn
if (amount === 'auto') {
amount = await Util.fetchRecommendedShards(this.token);
@@ -302,7 +302,7 @@ class ShardingManager extends EventEmitter {
* @param {MultipleShardRespawnOptions} [options] Options for respawning shards
* @returns {Promise<Collection<string, Shard>>}
*/
async respawnAll({ shardDelay = 5000, respawnDelay = 500, timeout = 30000 } = {}) {
async respawnAll({ shardDelay = 5_000, respawnDelay = 500, timeout = 30_000 } = {}) {
let s = 0;
for (const shard of this.shards.values()) {
const promises = [shard.respawn({ respawnDelay, timeout })];