diff --git a/lib/Voice/VoiceConnection.js b/lib/Voice/VoiceConnection.js index ebe6604fb..ea2f4812b 100644 --- a/lib/Voice/VoiceConnection.js +++ b/lib/Voice/VoiceConnection.js @@ -63,7 +63,7 @@ var VoiceConnection = (function (_EventEmitter) { } }; - VoiceConnection.prototype.playRawStream = function playRawStream(stream) { + VoiceConnection.prototype.playStream = function playStream(stream) { var self = this; @@ -196,21 +196,20 @@ var VoiceConnection = (function (_EventEmitter) { return new Promise(function (resolve, reject) { _this.encoder.encodeFile(stream)["catch"](error).then(function (data) { self.streamProc = data.proc; - var intent = self.playRawStream(data.stream); + var intent = self.playStream(data.stream); resolve(intent); callback(null, intent); }); function error() { var e = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; - console.log(e); reject(e); callback(e); } }); }; - VoiceConnection.prototype.playStream = function playStream(stream) { + VoiceConnection.prototype.playRawStream = function playRawStream(stream) { var _this2 = this; var callback = arguments.length <= 1 || arguments[1] === undefined ? function (err, str) {} : arguments[1]; @@ -220,14 +219,13 @@ var VoiceConnection = (function (_EventEmitter) { _this2.encoder.encodeStream(stream)["catch"](error).then(function (data) { self.streamProc = data.proc; self.instream = data.instream; - var intent = self.playRawStream(data.stream); + var intent = self.playStream(data.stream); resolve(intent); callback(null, intent); }); function error() { var e = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; - console.log(e); reject(e); callback(e); } diff --git a/src/Voice/VoiceConnection.js b/src/Voice/VoiceConnection.js index 9e053ad50..040d00ea0 100644 --- a/src/Voice/VoiceConnection.js +++ b/src/Voice/VoiceConnection.js @@ -56,7 +56,7 @@ class VoiceConnection extends EventEmitter { } } - playRawStream(stream) { + playStream(stream) { var self = this; @@ -193,20 +193,19 @@ class VoiceConnection extends EventEmitter { .catch(error) .then(data => { self.streamProc = data.proc; - var intent = self.playRawStream(data.stream); + var intent = self.playStream(data.stream); resolve(intent); callback(null, intent); }); function error(e = true) { - console.log(e); reject(e); callback(e); } }) } - playStream(stream, callback = function (err, str) { }) { + playRawStream(stream, callback = function (err, str) { }) { var self = this; return new Promise((resolve, reject) => { this.encoder @@ -215,13 +214,12 @@ class VoiceConnection extends EventEmitter { .then(data => { self.streamProc = data.proc; self.instream = data.instream; - var intent = self.playRawStream(data.stream); + var intent = self.playStream(data.stream); resolve(intent); callback(null, intent); }); function error(e = true) { - console.log(e); reject(e); callback(e); } diff --git a/test/bot.1.js b/test/bot.1.js index c15b05e5d..cc2262f19 100644 --- a/test/bot.1.js +++ b/test/bot.1.js @@ -4,6 +4,7 @@ var request = require("superagent"); client.on("debug", (m) => console.log("[debug]", m)); client.on("warn", (m) => console.log("[warn]", m)); var start = Date.now(); + client.on("message", m => { if (m.content === "&init") { for (var channel of m.channel.server.channels) { @@ -38,10 +39,8 @@ client.on("message", m => { if (client.internal.voiceConnection) { client.reply(m, "ok, I'll play that for you " + rest); var connection = client.internal.voiceConnection; - - var request = require("request"); - connection.playStream(request(rest)); + connection.playFile(rest); } } });