diff --git a/src/sharding/Shard.js b/src/sharding/Shard.js index 7a426f0ad..3ba7dd1f0 100644 --- a/src/sharding/Shard.js +++ b/src/sharding/Shard.js @@ -112,6 +112,15 @@ class Shard extends EventEmitter { return this.process; } + /** + * Kills this shard. + */ + kill() { + this.process.removeListener('exit', this._exitListener); + this.process.kill(); + this._handleExit(false); + } + /** * Kills and restarts the shard's process. * @param {number} [delay=500] How long to wait between killing the process and restarting it (in milliseconds) @@ -119,9 +128,7 @@ class Shard extends EventEmitter { * @returns {Promise} */ async respawn(delay = 500, waitForReady = true) { - this.process.removeListener('exit', this._exitListener); - this.process.kill(); - this._handleExit(false); + this.kill(); if (delay > 0) await Util.delayFor(delay); return this.spawn(waitForReady); }