mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
Reimplement StreamDispatcher error and start event in docs, emit error instead of debug if there are listeners for errors
This commit is contained in:
@@ -70,7 +70,11 @@ class StreamDispatcher extends Writable {
|
|||||||
if (typeof bitrate !== 'undefined') this.setBitrate(bitrate);
|
if (typeof bitrate !== 'undefined') this.setBitrate(bitrate);
|
||||||
|
|
||||||
const streamError = err => {
|
const streamError = err => {
|
||||||
this.emit('warn', err);
|
/**
|
||||||
|
* Emitted when the dispatcher encounters an error.
|
||||||
|
* @event StreamDispatcher#error
|
||||||
|
*/
|
||||||
|
this.emit(this.listenerCount('error') > 0 ? 'error' : 'warn', err);
|
||||||
this.destroy();
|
this.destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -86,7 +90,14 @@ class StreamDispatcher extends Writable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_write(chunk, enc, done) {
|
_write(chunk, enc, done) {
|
||||||
if (!this.startTime) this.startTime = Date.now();
|
if (!this.startTime) {
|
||||||
|
/**
|
||||||
|
* Emitted once the stream has started to play.
|
||||||
|
* @event StreamDispatcher#start
|
||||||
|
*/
|
||||||
|
this.emit('start');
|
||||||
|
this.startTime = Date.now();
|
||||||
|
}
|
||||||
this._playChunk(chunk);
|
this._playChunk(chunk);
|
||||||
this._step(done);
|
this._step(done);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user