mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
Fix ESLint and handle stream errors
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
const Collection = require('../../../util/Collection');
|
||||
const StreamDispatcher = require('./StreamDispatcher');
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,8 +29,8 @@ nonce.fill(0);
|
||||
* @extends {stream.Writable}
|
||||
*/
|
||||
class StreamDispatcher extends Writable {
|
||||
constructor(player, { seek = 0, volume = 1, passes = 1, fec, plp, bitrate = 96, highWaterMark = 4096 } = {}, streams) {
|
||||
const streamOptions = { seek, volume, passes, fec, plp, bitrate, highWaterMark };
|
||||
constructor(player, { seek = 0, volume = 1, passes = 1, fec, plp, bitrate = 96 } = {}, streams) {
|
||||
const streamOptions = { seek, volume, passes, fec, plp, bitrate };
|
||||
super(streamOptions);
|
||||
/**
|
||||
* The Audio Player that controls this dispatcher
|
||||
@@ -67,6 +67,15 @@ class StreamDispatcher extends Writable {
|
||||
if (typeof fec !== 'undefined') this.setFEC(fec);
|
||||
if (typeof plp !== 'undefined') this.setPLP(plp);
|
||||
if (typeof bitrate !== 'undefined') this.setBitrate(bitrate);
|
||||
|
||||
const streamError = err => {
|
||||
this.emit('warn', err);
|
||||
this.destroy();
|
||||
};
|
||||
|
||||
if (this.streams.ffmpeg) this.streams.ffmpeg.on('error', streamError);
|
||||
if (this.streams.opus) this.streams.opus.on('error', streamError);
|
||||
if (this.streams.volume) this.streams.volume.on('error', streamError);
|
||||
}
|
||||
|
||||
get _sdata() {
|
||||
|
||||
@@ -16,7 +16,7 @@ const FFMPEG_ARGUMENTS = [
|
||||
* @extends {EventEmitter}
|
||||
*/
|
||||
class BasePlayer extends EventEmitter {
|
||||
constructor(voiceConnection) {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.dispatcher = null;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
const prism = require('prism-media');
|
||||
const BroadcastDispatcher = require('../dispatcher/BroadcastDispatcher');
|
||||
const BasePlayer = require('./BasePlayer');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user