Handle unavailable guild, fix default getChannelLogs limit

This commit is contained in:
abalabahaha
2016-01-18 17:46:15 -08:00
parent 94f067cc51
commit 68435f0619
6 changed files with 65 additions and 70 deletions

View File

@@ -167,12 +167,17 @@ export default class Client extends EventEmitter {
}
// def getChannelLogs
getChannelLogs(where, limit = 500, options = {}, callback = (/*err, logs*/) => { }) {
getChannelLogs(where, limit = 50, options = {}, callback = (/*err, logs*/) => { }) {
if (typeof options === "function") {
// options is the callback
callback = options;
options = {};
}
else if (typeof limit === "function") {
// options is the callback
callback = limit;
limit = 50;
}
return this.internal.getChannelLogs(where, limit, options)
.then(dataCallback(callback), errorCallback(callback));

View File

@@ -86,7 +86,7 @@ export default class InternalClient {
return reject(error);
}
}else{
resolve(data.body);
resolve(data.body);
}
});
});
@@ -472,7 +472,7 @@ export default class InternalClient {
}
// def getChannelLogs
getChannelLogs(_channel, limit = 500, options = {}) {
getChannelLogs(_channel, limit = 50, options = {}) {
return this.resolver.resolveChannel(_channel)
.then(channel => {
var qsObject = {limit};
@@ -1187,7 +1187,7 @@ export default class InternalClient {
break;
case PacketType.SERVER_CREATE:
var server = self.servers.get("id", data.id);
if (!server) {
if (!server && !data.unavailable) {
server = new Server(data, client)
self.servers.add(server);
client.emit("serverCreated", server);
@@ -1195,8 +1195,7 @@ export default class InternalClient {
break;
case PacketType.SERVER_DELETE:
var server = self.servers.get("id", data.id);
if (server) {
if (server && !data.unavailable) {
for (var channel of server.channels) {
self.channels.remove(channel);
}