Merge pull request #62 from SimonSchick/master

Cleaned up Client.js and a bit of InternalClient.js
This commit is contained in:
Amish Shah
2015-11-24 16:39:34 +00:00
3 changed files with 319 additions and 727 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -54,16 +54,11 @@ class InternalClient {
//def leaveVoiceChannel
leaveVoiceChannel() {
var self = this;
return new Promise((resolve, reject) => {
if (self.voiceConnection) {
self.voiceConnection.destroy();
self.voiceConnection = null;
resolve();
} else {
resolve();
}
});
return Promise.resolve();
}
//def awaitResponse
@@ -91,16 +86,14 @@ class InternalClient {
//def joinVoiceChannel
joinVoiceChannel(chann) {
var self = this;
return new Promise((resolve, reject) => {
var channel = self.resolver.resolveVoiceChannel(chann);
if (channel) {
self.leaveVoiceChannel().then(next);
function next() {
if (!channel) {
return Promise.reject(new Error("voice channel does not exist"));
}
return self.leaveVoiceChannel()
.then(() => {
return new Promise((resolve, reject) => {
var session, token, server = channel.server, endpoint;
var check = (m) => {
@@ -131,11 +124,7 @@ class InternalClient {
"self_deaf": false
}
});
}
} else {
reject(new Error("voice channel does not exist"));
}
});
});
}