mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
fix: voice not throwing errors on bad stream input (#2786)
This commit is contained in:
@@ -63,19 +63,21 @@ 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);
|
||||||
}
|
}
|
||||||
const type = options.type || 'unknown';
|
if (resource instanceof Readable || typeof resource === 'string') {
|
||||||
if (type === 'unknown') {
|
const type = options.type || 'unknown';
|
||||||
return this.player.playUnknown(resource, options);
|
if (type === 'unknown') {
|
||||||
} else if (type === 'converted') {
|
return this.player.playUnknown(resource, options);
|
||||||
return this.player.playPCMStream(resource, options);
|
} else if (type === 'converted') {
|
||||||
} else if (type === 'opus') {
|
return this.player.playPCMStream(resource, options);
|
||||||
return this.player.playOpusStream(resource, options);
|
} else if (type === 'opus') {
|
||||||
} else if (type === 'ogg/opus') {
|
return this.player.playOpusStream(resource, options);
|
||||||
if (!(resource instanceof Readable)) throw new Error('VOICE_PRISM_DEMUXERS_NEED_STREAM');
|
} else if (type === 'ogg/opus') {
|
||||||
return this.player.playOpusStream(resource.pipe(new prism.OggOpusDemuxer()), options);
|
if (!(resource instanceof Readable)) throw new Error('VOICE_PRISM_DEMUXERS_NEED_STREAM');
|
||||||
} else if (type === 'webm/opus') {
|
return this.player.playOpusStream(resource.pipe(new prism.OggOpusDemuxer()), options);
|
||||||
if (!(resource instanceof Readable)) throw new Error('VOICE_PRISM_DEMUXERS_NEED_STREAM');
|
} else if (type === 'webm/opus') {
|
||||||
return this.player.playOpusStream(resource.pipe(new prism.WebmOpusDemuxer()), options);
|
if (!(resource instanceof Readable)) throw new Error('VOICE_PRISM_DEMUXERS_NEED_STREAM');
|
||||||
|
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');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user