mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Added playStream and renamed some functions
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user