Possibly fix #404, #405, #409

This commit is contained in:
abalabahaha
2016-06-03 18:36:17 -07:00
parent 2bd7d9dc24
commit 6cd0561014
4 changed files with 29 additions and 11 deletions

View File

@@ -555,8 +555,7 @@ export default class InternalClient {
return Promise.reject(new Error("Client is not logged in!"));
}
return this.apiRequest("post", Endpoints.LOGOUT, true)
.then(() => {
var disconnect = () => {
if (this.websocket) {
this.websocket.close(1000);
this.websocket = null;
@@ -565,7 +564,15 @@ export default class InternalClient {
this.email = null;
this.password = null;
this.state = ConnectionState.DISCONNECTED;
});
return Promise.resolve();
};
if(!this.user.bot) {
return this.apiRequest("post", Endpoints.LOGOUT, true)
.then(disconnect);
} else {
disconnect();
}
}
// def startPM
@@ -1371,8 +1378,9 @@ export default class InternalClient {
return Promise.reject(new Error("Bitrate must be between 8-96kbps"));
}
data.bitrate *= 1000; // convert to bits before sending
if (data.bitrate) {
data.bitrate *= 1000; // convert to bits before sending
}
return this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, data)
.then(res => {

View File

@@ -6,9 +6,10 @@ import EventEmitter from "events";
import crypto from "crypto";
var savePaths = [
process.env.APPDATA || (process.platform == "darwin" ? process.env.HOME + "Library/Preference" : "/var/local"),
process.env.APPDATA || (process.platform == "darwin" ? process.env.HOME + "Library/Preferences" : "/var/local"),
process.env[(process.platform == "win32") ? "USERPROFILE" : "HOME"],
process.cwd()
process.cwd(),
"/tmp"
];
var algo = "aes-256-ctr";