Removed trailing spaces, added unbanMember and kickMember

This commit is contained in:
abalabahaha
2015-11-11 18:27:08 -08:00
parent bb716480b1
commit 3e37c5d91f
20 changed files with 320 additions and 176 deletions

View File

@@ -12,25 +12,25 @@ var VoicePacket = require("./VoicePacket.js");
class AudioEncoder{
constructor(){
if(opus){
if(opus){
this.opus = new opus.OpusEncoder(48000, 1);
}
this.choice = false;
}
opusBuffer(buffer){
return this.opus.encode(buffer, 1920);
}
getCommand(force){
if(this.choice && force)
return choice;
var choices = ["avconv", "ffmpeg"];
for(var choice of choices){
var p = cpoc.spawnSync(choice);
if(!p.error){
@@ -38,10 +38,10 @@ class AudioEncoder{
return choice;
}
}
return "help";
}
encodeStream(stream, callback=function(err, buffer){}){
var self = this;
return new Promise((resolve, reject) => {
@@ -53,9 +53,9 @@ class AudioEncoder{
"pipe:1",
"-i", "-"
]);
stream.pipe(enc.stdin);
enc.stdout.once("readable", function() {
callback(null, {
proc : enc,
@@ -68,19 +68,19 @@ class AudioEncoder{
instream : stream
});
});
enc.stdout.on("end", function() {
callback("end");
reject("end");
});
enc.stdout.on("close", function() {
callback("close");
reject("close");
});
});
}
encodeFile(file, callback=function(err, buffer){}){
var self = this;
return new Promise((resolve, reject) => {
@@ -92,7 +92,7 @@ class AudioEncoder{
"pipe:1",
"-i", file
]);
enc.stdout.once("readable", function() {
callback(null, {
proc : enc,
@@ -103,12 +103,12 @@ class AudioEncoder{
stream : enc.stdout
});
});
enc.stdout.on("end", function() {
callback("end");
reject("end");
});
enc.stdout.on("close", function() {
callback("close");
reject("close");

View File

@@ -2,7 +2,7 @@
/*
Major credit to izy521 who is the creator of
https://github.com/izy521/discord.io,
without his help voice chat in discord.js would not have
been possible!
*/
@@ -88,7 +88,7 @@ class VoiceConnection extends EventEmitter {
self.playingIntent = retStream;
function send() {
if (!self.playingIntent || !self.playing) {
self.setSpeaking(false);
retStream.emit("end");
@@ -216,7 +216,7 @@ class VoiceConnection extends EventEmitter {
}
})
}
playRawStream(stream, callback = function (err, str) { }) {
var self = this;
return new Promise((resolve, reject) => {

View File

@@ -2,24 +2,24 @@
class VoicePacket{
constructor(data, sequence, time, ssrc){
var audioBuffer = data,
returnBuffer = new Buffer(audioBuffer.length + 12);
returnBuffer.fill(0);
returnBuffer[0] = 0x80;
returnBuffer[1] = 0x78;
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];
}
return returnBuffer;
}
}