mirror of
https://github.com/danbulant/discord.js
synced 2026-07-07 20:20:55 +00:00
feat: Shard#kill method (#2454)
* add shard#kill method * docs consistency
This commit is contained in:
parent
14aab1be38
commit
fc81924724
1 changed files with 10 additions and 3 deletions
|
|
@ -112,6 +112,15 @@ class Shard extends EventEmitter {
|
||||||
return this.process;
|
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.
|
* Kills and restarts the shard's process.
|
||||||
* @param {number} [delay=500] How long to wait between killing the process and restarting it (in milliseconds)
|
* @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<ChildProcess>}
|
* @returns {Promise<ChildProcess>}
|
||||||
*/
|
*/
|
||||||
async respawn(delay = 500, waitForReady = true) {
|
async respawn(delay = 500, waitForReady = true) {
|
||||||
this.process.removeListener('exit', this._exitListener);
|
this.kill();
|
||||||
this.process.kill();
|
|
||||||
this._handleExit(false);
|
|
||||||
if (delay > 0) await Util.delayFor(delay);
|
if (delay > 0) await Util.delayFor(delay);
|
||||||
return this.spawn(waitForReady);
|
return this.spawn(waitForReady);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue