From 687970a3ec5e71604483d5c31cd75a39f6c1a0aa Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Sat, 28 Nov 2015 22:19:17 +0100 Subject: [PATCH] Prevent error when trying to close stream by assuming all streams have end/destroy methods --- src/Voice/VoiceConnection.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Voice/VoiceConnection.js b/src/Voice/VoiceConnection.js index 688ca22e5..4e4cb01bf 100644 --- a/src/Voice/VoiceConnection.js +++ b/src/Voice/VoiceConnection.js @@ -61,8 +61,15 @@ export default class VoiceConnection extends EventEmitter { this.playing = false; this.playingIntent = null; if(this.instream){ - this.instream.end(); - this.instream.destroy(); + //not all streams implement these... + //and even file stream don't seem to implement them properly... + if(this.instream.end) { + this.instream.end(); + } + if(this.instream.destroy) { + this.instream.destroy(); + } + this.instream = null; } }