From 8607a2449cb4c3db1149397c7b1f1de0f8f3ce3a Mon Sep 17 00:00:00 2001 From: Aaron Scherer Date: Tue, 9 Feb 2016 09:38:48 -0800 Subject: [PATCH 1/7] Allow seeking for FFmpeg --- src/Voice/AudioEncoder.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Voice/AudioEncoder.js b/src/Voice/AudioEncoder.js index 6c74d7423..0ec6202aa 100644 --- a/src/Voice/AudioEncoder.js +++ b/src/Voice/AudioEncoder.js @@ -66,6 +66,7 @@ export default class AudioEncoder { '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), + '-ss', (options.seek || 0), '-ac', 2, 'pipe:1' ], {stdio: ['pipe', 'pipe', 'ignore']}); @@ -100,6 +101,7 @@ export default class AudioEncoder { '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), + '-ss', (options.seek || 0), '-ac', 2, 'pipe:1' ], { stdio: ['pipe', 'pipe', 'ignore'] }); From c7103f89305ba3fef149b369521d0b6d242bdc3e Mon Sep 17 00:00:00 2001 From: Aaron Scherer Date: Tue, 9 Feb 2016 09:39:44 -0800 Subject: [PATCH 2/7] Update AudioEncoder.js --- lib/Voice/AudioEncoder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Voice/AudioEncoder.js b/lib/Voice/AudioEncoder.js index 3bb45e95b..f6d21804c 100644 --- a/lib/Voice/AudioEncoder.js +++ b/lib/Voice/AudioEncoder.js @@ -81,7 +81,7 @@ var AudioEncoder = (function () { AudioEncoder.prototype.encodeStream = function encodeStream(stream, options) { var self = this; return new Promise(function (resolve, reject) { - var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', '-', '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); + var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', '-', '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ss', (options.seek || 0), '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); stream.pipe(enc.stdin); @@ -107,7 +107,7 @@ var AudioEncoder = (function () { AudioEncoder.prototype.encodeFile = function encodeFile(file, options) { var self = this; return new Promise(function (resolve, reject) { - var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', file, '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); + var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', file, '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ss', (options.seek || 0), '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); enc.stdout.once("readable", function () { resolve({ From b84af789c6bdecb028d19da69b8a23f787031dfb Mon Sep 17 00:00:00 2001 From: Aaron Scherer Date: Tue, 9 Feb 2016 09:42:05 -0800 Subject: [PATCH 3/7] Update docs_voiceconnection.rst --- docs/docs_voiceconnection.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs_voiceconnection.rst b/docs/docs_voiceconnection.rst index 6c99f5430..29bf3f8c7 100644 --- a/docs/docs_voiceconnection.rst +++ b/docs/docs_voiceconnection.rst @@ -64,7 +64,7 @@ Plays a file to the voice channel. The file can be in practically any format; if In addition to a file path local to your computer, it can also accept a URL, however this is not recommended as the entire content of the URL will be read before any playback starts. This can cause delays from seconds to minutes - you can use `playRawStream` with a Stream obtained from the URL instead. -The `options` object can be used to control playback properties, currently, it only allows setting the volume using the `volume` property, which can be in any of the following formats: +The `options` object can be used to control playback properties, currently, it currently allows setting the seek (in seconds), and setting the volume using the `volume` property, which can be in any of the following formats: - A number representing the linear change in volume; 1 is equal to no change, 0 is completely silent, 0.5 is half the regular volume and 2 is double the regular volume. - A string representing the linear change in volume, if this is more convenient for you. From 9ff798a8bc415fdacc0ed476a5c89395417faaba Mon Sep 17 00:00:00 2001 From: Aaron Scherer Date: Tue, 9 Feb 2016 09:42:37 -0800 Subject: [PATCH 4/7] Update docs_voiceconnection.rst --- docs/docs_voiceconnection.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs_voiceconnection.rst b/docs/docs_voiceconnection.rst index 29bf3f8c7..8a5b9f5cb 100644 --- a/docs/docs_voiceconnection.rst +++ b/docs/docs_voiceconnection.rst @@ -64,7 +64,7 @@ Plays a file to the voice channel. The file can be in practically any format; if In addition to a file path local to your computer, it can also accept a URL, however this is not recommended as the entire content of the URL will be read before any playback starts. This can cause delays from seconds to minutes - you can use `playRawStream` with a Stream obtained from the URL instead. -The `options` object can be used to control playback properties, currently, it currently allows setting the seek (in seconds), and setting the volume using the `volume` property, which can be in any of the following formats: +The `options` object can be used to control playback properties, currently, it currently allows setting the seek (in seconds) using the `seek` property, and the volume using the `volume` property, which can be in any of the following formats: - A number representing the linear change in volume; 1 is equal to no change, 0 is completely silent, 0.5 is half the regular volume and 2 is double the regular volume. - A string representing the linear change in volume, if this is more convenient for you. From 9fc5a752f8780b46d1d52ba68c8a472a9ffb4ccb Mon Sep 17 00:00:00 2001 From: abalabahaha Date: Thu, 11 Feb 2016 10:30:06 -0800 Subject: [PATCH 5/7] colorAsHex should return hex (fixes #188) --- lib/Structures/Role.js | 2 +- lib/Util/TokenCacher-shim.js | 24 ++++++++++++------------ src/Structures/Role.js | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Structures/Role.js b/lib/Structures/Role.js index f32eb0e4e..79eed38df 100644 --- a/lib/Structures/Role.js +++ b/lib/Structures/Role.js @@ -130,7 +130,7 @@ var Role = (function () { }; Role.prototype.colorAsHex = function colorAsHex() { - var val = this.color.toString(); + var val = this.color.toString(16); while (val.length < 6) { val = "0" + val; } diff --git a/lib/Util/TokenCacher-shim.js b/lib/Util/TokenCacher-shim.js index 53412d365..f483e9575 100644 --- a/lib/Util/TokenCacher-shim.js +++ b/lib/Util/TokenCacher-shim.js @@ -6,23 +6,23 @@ exports.__esModule = true; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var TokenCacher = (function () { - function TokenCacher() { - _classCallCheck(this, TokenCacher); - } + function TokenCacher() { + _classCallCheck(this, TokenCacher); + } - TokenCacher.prototype.setToken = function setToken() {}; + TokenCacher.prototype.setToken = function setToken() {}; - TokenCacher.prototype.save = function save() {}; + TokenCacher.prototype.save = function save() {}; - TokenCacher.prototype.getToken = function getToken() { - return null; - }; + TokenCacher.prototype.getToken = function getToken() { + return null; + }; - TokenCacher.prototype.init = function init(ind) { - this.done = true; - }; + TokenCacher.prototype.init = function init(ind) { + this.done = true; + }; - return TokenCacher; + return TokenCacher; })(); exports["default"] = TokenCacher; diff --git a/src/Structures/Role.js b/src/Structures/Role.js index 770079c31..3c3357c51 100644 --- a/src/Structures/Role.js +++ b/src/Structures/Role.js @@ -125,7 +125,7 @@ export default class Role { } colorAsHex(){ - var val = this.color.toString(); + var val = this.color.toString(16); while(val.length < 6){ val = "0" + val; } From 701c0ca9c4d950d5574bd6b2b78d2cbb80635823 Mon Sep 17 00:00:00 2001 From: calc84maniac Date: Thu, 11 Feb 2016 10:34:21 -0800 Subject: [PATCH 6/7] Let updateDetails use data.email if possible (thanks @calc84maniac) --- lib/Client/InternalClient.js | 2 +- src/Client/InternalClient.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Client/InternalClient.js b/lib/Client/InternalClient.js index 8ceecd8b2..1d005160c 100644 --- a/lib/Client/InternalClient.js +++ b/lib/Client/InternalClient.js @@ -1147,7 +1147,7 @@ var InternalClient = (function () { //def updateDetails InternalClient.prototype.updateDetails = function updateDetails(data) { - if (!this.email) { + if (!this.email && !data.email) { throw new Error("Can't use updateDetails because only a token has been used for login!"); } return this.apiRequest("patch", _Constants.Endpoints.ME, true, { diff --git a/src/Client/InternalClient.js b/src/Client/InternalClient.js index 5a348f91e..19ba9cf58 100644 --- a/src/Client/InternalClient.js +++ b/src/Client/InternalClient.js @@ -969,7 +969,7 @@ export default class InternalClient { //def updateDetails updateDetails(data) { - if(!this.email) { + if(!this.email && !data.email) { throw new Error("Can't use updateDetails because only a token has been used for login!"); } return this.apiRequest("patch", Endpoints.ME, true, { From 5132c9ade4aa887814dba57459f98d3a1b2bebc3 Mon Sep 17 00:00:00 2001 From: hydrabolt Date: Fri, 12 Feb 2016 21:03:27 +0000 Subject: [PATCH 7/7] added large_threshold --- lib/Client/InternalClient.js | 1 + lib/Util/TokenCacher-shim.js | 24 ++++++++++++------------ lib/Voice/AudioEncoder.js | 4 ++-- lib/Voice/VoicePacket.js | 26 +++++++++++++------------- src/Client/InternalClient.js | 1 + 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/lib/Client/InternalClient.js b/lib/Client/InternalClient.js index 1d005160c..9bd48c715 100644 --- a/lib/Client/InternalClient.js +++ b/lib/Client/InternalClient.js @@ -1287,6 +1287,7 @@ var InternalClient = (function () { token: self.token, v: 3, compress: self.client.options.compress, + large_threshold: 250, properties: { "$os": "discord.js", "$browser": "discord.js", diff --git a/lib/Util/TokenCacher-shim.js b/lib/Util/TokenCacher-shim.js index f483e9575..53412d365 100644 --- a/lib/Util/TokenCacher-shim.js +++ b/lib/Util/TokenCacher-shim.js @@ -6,23 +6,23 @@ exports.__esModule = true; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var TokenCacher = (function () { - function TokenCacher() { - _classCallCheck(this, TokenCacher); - } + function TokenCacher() { + _classCallCheck(this, TokenCacher); + } - TokenCacher.prototype.setToken = function setToken() {}; + TokenCacher.prototype.setToken = function setToken() {}; - TokenCacher.prototype.save = function save() {}; + TokenCacher.prototype.save = function save() {}; - TokenCacher.prototype.getToken = function getToken() { - return null; - }; + TokenCacher.prototype.getToken = function getToken() { + return null; + }; - TokenCacher.prototype.init = function init(ind) { - this.done = true; - }; + TokenCacher.prototype.init = function init(ind) { + this.done = true; + }; - return TokenCacher; + return TokenCacher; })(); exports["default"] = TokenCacher; diff --git a/lib/Voice/AudioEncoder.js b/lib/Voice/AudioEncoder.js index f6d21804c..bf13afbde 100644 --- a/lib/Voice/AudioEncoder.js +++ b/lib/Voice/AudioEncoder.js @@ -81,7 +81,7 @@ var AudioEncoder = (function () { AudioEncoder.prototype.encodeStream = function encodeStream(stream, options) { var self = this; return new Promise(function (resolve, reject) { - var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', '-', '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ss', (options.seek || 0), '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); + var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', '-', '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ss', options.seek || 0, '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); stream.pipe(enc.stdin); @@ -107,7 +107,7 @@ var AudioEncoder = (function () { AudioEncoder.prototype.encodeFile = function encodeFile(file, options) { var self = this; return new Promise(function (resolve, reject) { - var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', file, '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ss', (options.seek || 0), '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); + var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', file, '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ss', options.seek || 0, '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); enc.stdout.once("readable", function () { resolve({ diff --git a/lib/Voice/VoicePacket.js b/lib/Voice/VoicePacket.js index 445f9d6c4..e62240c4c 100644 --- a/lib/Voice/VoicePacket.js +++ b/lib/Voice/VoicePacket.js @@ -5,24 +5,24 @@ exports.__esModule = true; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var VoicePacket = function VoicePacket(data, sequence, time, ssrc) { - _classCallCheck(this, VoicePacket); + _classCallCheck(this, VoicePacket); - var audioBuffer = data, - returnBuffer = new Buffer(audioBuffer.length + 12); + var audioBuffer = data, + returnBuffer = new Buffer(audioBuffer.length + 12); - returnBuffer.fill(0); - returnBuffer[0] = 0x80; - returnBuffer[1] = 0x78; + returnBuffer.fill(0); + returnBuffer[0] = 0x80; + returnBuffer[1] = 0x78; - returnBuffer.writeUIntBE(sequence, 2, 2); - returnBuffer.writeUIntBE(time, 4, 4); - returnBuffer.writeUIntBE(ssrc, 8, 4); + returnBuffer.writeUIntBE(sequence, 2, 2); + returnBuffer.writeUIntBE(time, 4, 4); + returnBuffer.writeUIntBE(ssrc, 8, 4); - for (var i = 0; i < audioBuffer.length; i++) { - returnBuffer[i + 12] = audioBuffer[i]; - } + for (var i = 0; i < audioBuffer.length; i++) { + returnBuffer[i + 12] = audioBuffer[i]; + } - return returnBuffer; + return returnBuffer; }; exports["default"] = VoicePacket; diff --git a/src/Client/InternalClient.js b/src/Client/InternalClient.js index 19ba9cf58..480a80cab 100644 --- a/src/Client/InternalClient.js +++ b/src/Client/InternalClient.js @@ -1086,6 +1086,7 @@ export default class InternalClient { token: self.token, v: 3, compress: self.client.options.compress, + large_threshold : 250, properties: { "$os": "discord.js", "$browser": "discord.js",