Cherry pick commits from indev

This commit is contained in:
Schuyler Cebulskie
2016-10-27 19:48:34 -04:00
parent 96e46cbf37
commit 1841122a8f
8 changed files with 21 additions and 49 deletions

View File

@@ -236,8 +236,8 @@ class Client extends EventEmitter {
destroy() {
for (const t of this._timeouts) clearTimeout(t);
for (const i of this._intervals) clearInterval(i);
this._timeouts = [];
this._intervals = [];
this._timeouts.clear();
this._intervals.clear();
this.token = null;
this.email = null;
this.password = null;

View File

@@ -58,10 +58,10 @@ class ClientManager {
}
destroy() {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
this.client.ws.destroy();
if (!this.client.user.bot) {
this.client.rest.methods.logout().then(resolve);
this.client.rest.methods.logout().then(resolve, reject);
} else {
resolve();
}

View File

@@ -80,7 +80,7 @@ class ClientVoiceManager {
return new Promise((resolve, reject) => {
if (this.pending.get(channel.guild.id)) throw new Error('Already connecting to this guild\'s voice server.');
if (!channel.permissionsFor(this.client.user).hasPermission('CONNECT')) {
if (!channel.joinable) {
throw new Error('You do not have permission to join this voice channel');
}

View File

@@ -142,7 +142,6 @@ class VoiceWebSocket extends EventEmitter {
* Called whenever the connection to the WebSocket Server is lost
*/
onClose() {
// TODO see if the connection is open before reconnecting
if (!this.dead) this.client.setTimeout(this.connect.bind(this), this.attempts * 1000);
}

View File

@@ -1,5 +1,6 @@
/**
* Represents a Secret Key used in encryption over voice
* @private
*/
class SecretKey {
constructor(key) {