mirror of
https://github.com/danbulant/discord.js
synced 2026-05-29 20:30:38 +00:00
voice: cleanup internals whether end() or destroy() is called
This commit is contained in:
parent
4009986bc8
commit
6aa792f9ab
1 changed files with 6 additions and 1 deletions
|
|
@ -67,6 +67,7 @@ class StreamDispatcher extends Writable {
|
|||
this.count = 0;
|
||||
|
||||
this.on('finish', () => {
|
||||
this._cleanup();
|
||||
// Still emitting end for backwards compatibility, probably remove it in the future!
|
||||
this.emit('end');
|
||||
this._setSpeaking(0);
|
||||
|
|
@ -114,12 +115,16 @@ class StreamDispatcher extends Writable {
|
|||
}
|
||||
|
||||
_destroy(err, cb) {
|
||||
this._cleanup();
|
||||
super._destroy(err, cb);
|
||||
}
|
||||
|
||||
_cleanup() {
|
||||
if (this.player.dispatcher === this) this.player.dispatcher = null;
|
||||
const { streams } = this;
|
||||
if (streams.broadcast) streams.broadcast.dispatchers.delete(this);
|
||||
if (streams.opus) streams.opus.destroy();
|
||||
if (streams.ffmpeg) streams.ffmpeg.destroy();
|
||||
super._destroy(err, cb);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue