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

@@ -86,7 +86,7 @@ var Client = (function (_EventEmitter) {
var callback = arguments.length <= 0 || arguments[0] === undefined ? function () /*err, {}*/{} : arguments[0];
this.internal.logout().then(function () {
return this.internal.logout().then(function () {
return _this.internal.disconnected(true);
}).then(dataCallback(callback), errorCallback(callback));
};
@@ -179,7 +179,7 @@ var Client = (function (_EventEmitter) {
// def getChannelLogs
Client.prototype.getChannelLogs = function getChannelLogs(where) {
var limit = arguments.length <= 1 || arguments[1] === undefined ? 500 : arguments[1];
var limit = arguments.length <= 1 || arguments[1] === undefined ? 50 : arguments[1];
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var callback = arguments.length <= 3 || arguments[3] === undefined ? function () /*err, logs*/{} : arguments[3];
@@ -187,6 +187,10 @@ var Client = (function (_EventEmitter) {
// 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

@@ -588,7 +588,7 @@ var InternalClient = (function () {
InternalClient.prototype.getChannelLogs = function getChannelLogs(_channel) {
var _this15 = this;
var limit = arguments.length <= 1 || arguments[1] === undefined ? 500 : arguments[1];
var limit = arguments.length <= 1 || arguments[1] === undefined ? 50 : arguments[1];
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
return this.resolver.resolveChannel(_channel).then(function (channel) {
@@ -1373,7 +1373,7 @@ var InternalClient = (function () {
break;
case _Constants.PacketType.SERVER_CREATE:
var server = self.servers.get("id", data.id);
if (!server) {
if (!server && !data.unavailable) {
server = new _StructuresServer2["default"](data, client);
self.servers.add(server);
client.emit("serverCreated", server);
@@ -1381,8 +1381,7 @@ var InternalClient = (function () {
break;
case _Constants.PacketType.SERVER_DELETE:
var server = self.servers.get("id", data.id);
if (server) {
if (server && !data.unavailable) {
for (var _iterator5 = server.channels, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) {
var _ref5;