fix: voice not throwing errors on bad stream input (#2786)

This commit is contained in:
Amish Shah
2018-08-25 19:41:07 +01:00
parent 9b329a457c
commit 6f62d7d816

View File

@@ -63,6 +63,7 @@ class PlayInterface {
if (!this.player.playBroadcast) throw new Error('VOICE_PLAY_INTERFACE_NO_BROADCAST'); if (!this.player.playBroadcast) throw new Error('VOICE_PLAY_INTERFACE_NO_BROADCAST');
return this.player.playBroadcast(resource, options); return this.player.playBroadcast(resource, options);
} }
if (resource instanceof Readable || typeof resource === 'string') {
const type = options.type || 'unknown'; const type = options.type || 'unknown';
if (type === 'unknown') { if (type === 'unknown') {
return this.player.playUnknown(resource, options); return this.player.playUnknown(resource, options);
@@ -77,6 +78,7 @@ class PlayInterface {
if (!(resource instanceof Readable)) throw new Error('VOICE_PRISM_DEMUXERS_NEED_STREAM'); if (!(resource instanceof Readable)) throw new Error('VOICE_PRISM_DEMUXERS_NEED_STREAM');
return this.player.playOpusStream(resource.pipe(new prism.WebmOpusDemuxer()), options); return this.player.playOpusStream(resource.pipe(new prism.WebmOpusDemuxer()), options);
} }
}
throw new Error('VOICE_PLAY_INTERFACE_BAD_TYPE'); throw new Error('VOICE_PLAY_INTERFACE_BAD_TYPE');
} }