mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
Builds for the latest changes
This commit is contained in:
@@ -100,6 +100,7 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.sendMessage(where, content, options).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.sendMessage(where, content, options).then(dataCallback(callback), errorCallback(callback));
|
||||||
@@ -122,6 +123,7 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg = this.internal.resolver.resolveMessage(where);
|
var msg = this.internal.resolver.resolveMessage(where);
|
||||||
@@ -153,6 +155,7 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.deleteMessage(msg, options).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.deleteMessage(msg, options).then(dataCallback(callback), errorCallback(callback));
|
||||||
@@ -167,6 +170,7 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.updateMessage(msg, content, options).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.updateMessage(msg, content, options).then(dataCallback(callback), errorCallback(callback));
|
||||||
@@ -182,6 +186,7 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.getChannelLogs(where, limit, options).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.getChannelLogs(where, limit, options).then(dataCallback(callback), errorCallback(callback));
|
||||||
@@ -229,6 +234,20 @@ var Client = (function (_EventEmitter) {
|
|||||||
return this.internal.leaveServer(server).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.leaveServer(server).then(dataCallback(callback), errorCallback(callback));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// def updateServer
|
||||||
|
|
||||||
|
Client.prototype.updateServer = function updateServer(server, name, region) {
|
||||||
|
var callback = arguments.length <= 3 || arguments[3] === undefined ? function () /*err, srv*/{} : arguments[3];
|
||||||
|
|
||||||
|
if (typeof region === "function") {
|
||||||
|
// region is the callback
|
||||||
|
callback = region;
|
||||||
|
region = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.internal.updateServer(server, name, region).then(dataCallback(callback), errorCallback(callback));
|
||||||
|
};
|
||||||
|
|
||||||
// def deleteServer
|
// def deleteServer
|
||||||
|
|
||||||
Client.prototype.deleteServer = function deleteServer(server) {
|
Client.prototype.deleteServer = function deleteServer(server) {
|
||||||
@@ -246,6 +265,7 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof type === "function") {
|
if (typeof type === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = type;
|
callback = type;
|
||||||
|
type = "text";
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.createChannel(server, name, type).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.createChannel(server, name, type).then(dataCallback(callback), errorCallback(callback));
|
||||||
@@ -268,6 +288,7 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof length === "function") {
|
if (typeof length === "function") {
|
||||||
// length is the callback
|
// length is the callback
|
||||||
callback = length;
|
callback = length;
|
||||||
|
length = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.banMember(user, server, length).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.banMember(user, server, length).then(dataCallback(callback), errorCallback(callback));
|
||||||
@@ -298,6 +319,7 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof data === "function") {
|
if (typeof data === "function") {
|
||||||
// data is the callback
|
// data is the callback
|
||||||
callback = data;
|
callback = data;
|
||||||
|
data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.createRole(server, data).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.createRole(server, data).then(dataCallback(callback), errorCallback(callback));
|
||||||
@@ -312,6 +334,7 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof data === "function") {
|
if (typeof data === "function") {
|
||||||
// data is the callback
|
// data is the callback
|
||||||
callback = data;
|
callback = data;
|
||||||
|
data = null;
|
||||||
}
|
}
|
||||||
return this.internal.updateRole(role, data).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.updateRole(role, data).then(dataCallback(callback), errorCallback(callback));
|
||||||
};
|
};
|
||||||
@@ -396,6 +419,7 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.createInvite(chanServ, options).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.createInvite(chanServ, options).then(dataCallback(callback), errorCallback(callback));
|
||||||
@@ -434,9 +458,11 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof game === "function") {
|
if (typeof game === "function") {
|
||||||
// game is the callback
|
// game is the callback
|
||||||
callback = game;
|
callback = game;
|
||||||
|
game = null;
|
||||||
} else if (typeof idleStatus === "function") {
|
} else if (typeof idleStatus === "function") {
|
||||||
// idleStatus is the callback
|
// idleStatus is the callback
|
||||||
callback = idleStatus;
|
callback = idleStatus;
|
||||||
|
game = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.setStatus(idleStatus, game).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.setStatus(idleStatus, game).then(dataCallback(callback), errorCallback(callback));
|
||||||
@@ -562,12 +588,15 @@ var Client = (function (_EventEmitter) {
|
|||||||
if (typeof toSend === "function") {
|
if (typeof toSend === "function") {
|
||||||
// (msg, callback)
|
// (msg, callback)
|
||||||
callback = toSend;
|
callback = toSend;
|
||||||
|
toSend = null;
|
||||||
|
options = null;
|
||||||
} else {
|
} else {
|
||||||
// (msg, toSend, ...)
|
// (msg, toSend, ...)
|
||||||
if (options) {
|
if (options) {
|
||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
//(msg, toSend, callback)
|
//(msg, toSend, callback)
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = null;
|
||||||
ret = this.sendMessage(msg, toSend);
|
ret = this.sendMessage(msg, toSend);
|
||||||
} else {
|
} else {
|
||||||
//(msg, toSend, options, callback)
|
//(msg, toSend, options, callback)
|
||||||
|
|||||||
@@ -343,10 +343,28 @@ var InternalClient = (function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//def updateServer
|
||||||
|
|
||||||
|
InternalClient.prototype.updateServer = function updateServer(server, name, region) {
|
||||||
|
var _this6 = this;
|
||||||
|
|
||||||
|
var server = this.resolver.resolveServer(server);
|
||||||
|
if (!server) {
|
||||||
|
return Promise.reject(new Error("server did not resolve"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.apiRequest("patch", _Constants.Endpoints.SERVER(server.id), true, { name: name || server.name, region: region || server.region }).then(function (res) {
|
||||||
|
// wait until the name and region are updated
|
||||||
|
return waitFor(function () {
|
||||||
|
return _this6.servers.get("name", res.name) ? _this6.servers.get("name", res.name).region === res.region ? _this6.servers.get("id", res.id) : false : false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
//def leaveServer
|
//def leaveServer
|
||||||
|
|
||||||
InternalClient.prototype.leaveServer = function leaveServer(srv) {
|
InternalClient.prototype.leaveServer = function leaveServer(srv) {
|
||||||
var _this6 = this;
|
var _this7 = this;
|
||||||
|
|
||||||
var server = this.resolver.resolveServer(srv);
|
var server = this.resolver.resolveServer(srv);
|
||||||
if (!server) {
|
if (!server) {
|
||||||
@@ -369,24 +387,24 @@ var InternalClient = (function () {
|
|||||||
|
|
||||||
var chan = _ref2;
|
var chan = _ref2;
|
||||||
|
|
||||||
_this6.channels.remove(chan);
|
_this7.channels.remove(chan);
|
||||||
}
|
}
|
||||||
// remove server
|
// remove server
|
||||||
_this6.servers.remove(server);
|
_this7.servers.remove(server);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// def login
|
// def login
|
||||||
|
|
||||||
InternalClient.prototype.login = function login(email, password) {
|
InternalClient.prototype.login = function login(email, password) {
|
||||||
var _this7 = this;
|
var _this8 = this;
|
||||||
|
|
||||||
var client = this.client;
|
var client = this.client;
|
||||||
|
|
||||||
if (!this.tokenCacher.done) {
|
if (!this.tokenCacher.done) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
_this7.login(email, password).then(resolve)["catch"](reject);
|
_this8.login(email, password).then(resolve)["catch"](reject);
|
||||||
}, 20);
|
}, 20);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -399,7 +417,7 @@ var InternalClient = (function () {
|
|||||||
this.password = password;
|
this.password = password;
|
||||||
|
|
||||||
return this.getGateway().then(function (url) {
|
return this.getGateway().then(function (url) {
|
||||||
_this7.createWS(url);
|
_this8.createWS(url);
|
||||||
return tk;
|
return tk;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -417,23 +435,23 @@ var InternalClient = (function () {
|
|||||||
email: email,
|
email: email,
|
||||||
password: password
|
password: password
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
_this7.client.emit("debug", "direct API login, cached token was unavailable");
|
_this8.client.emit("debug", "direct API login, cached token was unavailable");
|
||||||
var token = res.token;
|
var token = res.token;
|
||||||
_this7.tokenCacher.setToken(email, password, token);
|
_this8.tokenCacher.setToken(email, password, token);
|
||||||
_this7.state = _ConnectionState2["default"].LOGGED_IN;
|
_this8.state = _ConnectionState2["default"].LOGGED_IN;
|
||||||
_this7.token = token;
|
_this8.token = token;
|
||||||
_this7.email = email;
|
_this8.email = email;
|
||||||
_this7.password = password;
|
_this8.password = password;
|
||||||
|
|
||||||
return _this7.getGateway().then(function (url) {
|
return _this8.getGateway().then(function (url) {
|
||||||
_this7.createWS(url);
|
_this8.createWS(url);
|
||||||
return token;
|
return token;
|
||||||
});
|
});
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
_this7.websocket = null;
|
_this8.websocket = null;
|
||||||
throw error;
|
throw error;
|
||||||
})["catch"](function (error) {
|
})["catch"](function (error) {
|
||||||
_this7.state = _ConnectionState2["default"].DISCONNECTED;
|
_this8.state = _ConnectionState2["default"].DISCONNECTED;
|
||||||
client.emit("disconnected");
|
client.emit("disconnected");
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
@@ -442,28 +460,28 @@ var InternalClient = (function () {
|
|||||||
// def logout
|
// def logout
|
||||||
|
|
||||||
InternalClient.prototype.logout = function logout() {
|
InternalClient.prototype.logout = function logout() {
|
||||||
var _this8 = this;
|
var _this9 = this;
|
||||||
|
|
||||||
if (this.state === _ConnectionState2["default"].DISCONNECTED || this.state === _ConnectionState2["default"].IDLE) {
|
if (this.state === _ConnectionState2["default"].DISCONNECTED || this.state === _ConnectionState2["default"].IDLE) {
|
||||||
return Promise.reject(new Error("Client is not logged in!"));
|
return Promise.reject(new Error("Client is not logged in!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.apiRequest("post", _Constants.Endpoints.LOGOUT, true).then(function () {
|
return this.apiRequest("post", _Constants.Endpoints.LOGOUT, true).then(function () {
|
||||||
if (_this8.websocket) {
|
if (_this9.websocket) {
|
||||||
_this8.websocket.close();
|
_this9.websocket.close();
|
||||||
_this8.websocket = null;
|
_this9.websocket = null;
|
||||||
}
|
}
|
||||||
_this8.token = null;
|
_this9.token = null;
|
||||||
_this8.email = null;
|
_this9.email = null;
|
||||||
_this8.password = null;
|
_this9.password = null;
|
||||||
_this8.state = _ConnectionState2["default"].DISCONNECTED;
|
_this9.state = _ConnectionState2["default"].DISCONNECTED;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// def startPM
|
// def startPM
|
||||||
|
|
||||||
InternalClient.prototype.startPM = function startPM(resUser) {
|
InternalClient.prototype.startPM = function startPM(resUser) {
|
||||||
var _this9 = this;
|
var _this10 = this;
|
||||||
|
|
||||||
var user = this.resolver.resolveUser(resUser);
|
var user = this.resolver.resolveUser(resUser);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@@ -473,7 +491,7 @@ var InternalClient = (function () {
|
|||||||
return this.apiRequest("post", _Constants.Endpoints.USER_CHANNELS(user.id), true, {
|
return this.apiRequest("post", _Constants.Endpoints.USER_CHANNELS(user.id), true, {
|
||||||
recipient_id: user.id
|
recipient_id: user.id
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
return _this9.private_channels.add(new _StructuresPMChannel2["default"](res, _this9.client));
|
return _this10.private_channels.add(new _StructuresPMChannel2["default"](res, _this10.client));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -488,19 +506,19 @@ var InternalClient = (function () {
|
|||||||
// def sendMessage
|
// def sendMessage
|
||||||
|
|
||||||
InternalClient.prototype.sendMessage = function sendMessage(where, _content) {
|
InternalClient.prototype.sendMessage = function sendMessage(where, _content) {
|
||||||
var _this10 = this;
|
var _this11 = this;
|
||||||
|
|
||||||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
|
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(where).then(function (destination) {
|
return this.resolver.resolveChannel(where).then(function (destination) {
|
||||||
//var destination;
|
//var destination;
|
||||||
var content = _this10.resolver.resolveString(_content);
|
var content = _this11.resolver.resolveString(_content);
|
||||||
|
|
||||||
return _this10.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(destination.id), true, {
|
return _this11.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(destination.id), true, {
|
||||||
content: content,
|
content: content,
|
||||||
tts: options.tts
|
tts: options.tts
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
return destination.messages.add(new _StructuresMessage2["default"](res, destination, _this10.client));
|
return destination.messages.add(new _StructuresMessage2["default"](res, destination, _this11.client));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -508,7 +526,7 @@ var InternalClient = (function () {
|
|||||||
// def deleteMessage
|
// def deleteMessage
|
||||||
|
|
||||||
InternalClient.prototype.deleteMessage = function deleteMessage(_message) {
|
InternalClient.prototype.deleteMessage = function deleteMessage(_message) {
|
||||||
var _this11 = this;
|
var _this12 = this;
|
||||||
|
|
||||||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
|
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
|
||||||
|
|
||||||
@@ -519,7 +537,7 @@ var InternalClient = (function () {
|
|||||||
|
|
||||||
var chain = options.wait ? delay(options.wait) : Promise.resolve();
|
var chain = options.wait ? delay(options.wait) : Promise.resolve();
|
||||||
return chain.then(function () {
|
return chain.then(function () {
|
||||||
return _this11.apiRequest("del", _Constants.Endpoints.CHANNEL_MESSAGE(message.channel.id, message.id), true);
|
return _this12.apiRequest("del", _Constants.Endpoints.CHANNEL_MESSAGE(message.channel.id, message.id), true);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return message.channel.messages.remove(message);
|
return message.channel.messages.remove(message);
|
||||||
});
|
});
|
||||||
@@ -528,7 +546,7 @@ var InternalClient = (function () {
|
|||||||
// def updateMessage
|
// def updateMessage
|
||||||
|
|
||||||
InternalClient.prototype.updateMessage = function updateMessage(msg, _content) {
|
InternalClient.prototype.updateMessage = function updateMessage(msg, _content) {
|
||||||
var _this12 = this;
|
var _this13 = this;
|
||||||
|
|
||||||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
|
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
|
||||||
|
|
||||||
@@ -544,23 +562,23 @@ var InternalClient = (function () {
|
|||||||
content: content,
|
content: content,
|
||||||
tts: options.tts
|
tts: options.tts
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
return message.channel.messages.update(message, new _StructuresMessage2["default"](res, message.channel, _this12.client));
|
return message.channel.messages.update(message, new _StructuresMessage2["default"](res, message.channel, _this13.client));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// def sendFile
|
// def sendFile
|
||||||
|
|
||||||
InternalClient.prototype.sendFile = function sendFile(where, _file) {
|
InternalClient.prototype.sendFile = function sendFile(where, _file) {
|
||||||
var _this13 = this;
|
var _this14 = this;
|
||||||
|
|
||||||
var name = arguments.length <= 2 || arguments[2] === undefined ? "image.png" : arguments[2];
|
var name = arguments.length <= 2 || arguments[2] === undefined ? "image.png" : arguments[2];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(where).then(function (channel) {
|
return this.resolver.resolveChannel(where).then(function (channel) {
|
||||||
return _this13.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(channel.id), true, null, {
|
return _this14.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(channel.id), true, null, {
|
||||||
name: name,
|
name: name,
|
||||||
file: _this13.resolver.resolveFile(_file)
|
file: _this14.resolver.resolveFile(_file)
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
return channel.messages.add(new _StructuresMessage2["default"](res, channel, _this13.client));
|
return channel.messages.add(new _StructuresMessage2["default"](res, channel, _this14.client));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -568,7 +586,7 @@ var InternalClient = (function () {
|
|||||||
// def getChannelLogs
|
// def getChannelLogs
|
||||||
|
|
||||||
InternalClient.prototype.getChannelLogs = function getChannelLogs(_channel) {
|
InternalClient.prototype.getChannelLogs = function getChannelLogs(_channel) {
|
||||||
var _this14 = this;
|
var _this15 = this;
|
||||||
|
|
||||||
var limit = arguments.length <= 1 || arguments[1] === undefined ? 500 : arguments[1];
|
var limit = arguments.length <= 1 || arguments[1] === undefined ? 500 : arguments[1];
|
||||||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
|
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
|
||||||
@@ -576,21 +594,21 @@ var InternalClient = (function () {
|
|||||||
return this.resolver.resolveChannel(_channel).then(function (channel) {
|
return this.resolver.resolveChannel(_channel).then(function (channel) {
|
||||||
var qsObject = { limit: limit };
|
var qsObject = { limit: limit };
|
||||||
if (options.before) {
|
if (options.before) {
|
||||||
var res = _this14.resolver.resolveMessage(options.before);
|
var res = _this15.resolver.resolveMessage(options.before);
|
||||||
if (res) {
|
if (res) {
|
||||||
qsObject.before = res;
|
qsObject.before = res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.after) {
|
if (options.after) {
|
||||||
var res = _this14.resolver.resolveMessage(options.after);
|
var res = _this15.resolver.resolveMessage(options.after);
|
||||||
if (res) {
|
if (res) {
|
||||||
qsObject.after = res;
|
qsObject.after = res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _this14.apiRequest("get", _Constants.Endpoints.CHANNEL_MESSAGES(channel.id) + "?" + _querystring2["default"].stringify(qsObject), true).then(function (res) {
|
return _this15.apiRequest("get", _Constants.Endpoints.CHANNEL_MESSAGES(channel.id) + "?" + _querystring2["default"].stringify(qsObject), true).then(function (res) {
|
||||||
return res.map(function (msg) {
|
return res.map(function (msg) {
|
||||||
return channel.messages.add(new _StructuresMessage2["default"](msg, channel, _this14.client));
|
return channel.messages.add(new _StructuresMessage2["default"](msg, channel, _this15.client));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -599,13 +617,13 @@ var InternalClient = (function () {
|
|||||||
// def getBans
|
// def getBans
|
||||||
|
|
||||||
InternalClient.prototype.getBans = function getBans(server) {
|
InternalClient.prototype.getBans = function getBans(server) {
|
||||||
var _this15 = this;
|
var _this16 = this;
|
||||||
|
|
||||||
server = this.resolver.resolveServer(server);
|
server = this.resolver.resolveServer(server);
|
||||||
|
|
||||||
return this.apiRequest("get", _Constants.Endpoints.SERVER_BANS(server.id), true).then(function (res) {
|
return this.apiRequest("get", _Constants.Endpoints.SERVER_BANS(server.id), true).then(function (res) {
|
||||||
return res.map(function (ban) {
|
return res.map(function (ban) {
|
||||||
return _this15.users.add(new _StructuresUser2["default"](ban.user, _this15.client));
|
return _this16.users.add(new _StructuresUser2["default"](ban.user, _this16.client));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -613,7 +631,7 @@ var InternalClient = (function () {
|
|||||||
// def createChannel
|
// def createChannel
|
||||||
|
|
||||||
InternalClient.prototype.createChannel = function createChannel(server, name) {
|
InternalClient.prototype.createChannel = function createChannel(server, name) {
|
||||||
var _this16 = this;
|
var _this17 = this;
|
||||||
|
|
||||||
var type = arguments.length <= 2 || arguments[2] === undefined ? "text" : arguments[2];
|
var type = arguments.length <= 2 || arguments[2] === undefined ? "text" : arguments[2];
|
||||||
|
|
||||||
@@ -625,23 +643,23 @@ var InternalClient = (function () {
|
|||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
var channel;
|
var channel;
|
||||||
if (res.type === "text") {
|
if (res.type === "text") {
|
||||||
channel = new _StructuresTextChannel2["default"](res, _this16.client, server);
|
channel = new _StructuresTextChannel2["default"](res, _this17.client, server);
|
||||||
} else {
|
} else {
|
||||||
channel = new _StructuresVoiceChannel2["default"](res, _this16.client, server);
|
channel = new _StructuresVoiceChannel2["default"](res, _this17.client, server);
|
||||||
}
|
}
|
||||||
return server.channels.add(_this16.channels.add(channel));
|
return server.channels.add(_this17.channels.add(channel));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// def deleteChannel
|
// def deleteChannel
|
||||||
|
|
||||||
InternalClient.prototype.deleteChannel = function deleteChannel(_channel) {
|
InternalClient.prototype.deleteChannel = function deleteChannel(_channel) {
|
||||||
var _this17 = this;
|
var _this18 = this;
|
||||||
|
|
||||||
return this.resolver.resolveChannel(_channel).then(function (channel) {
|
return this.resolver.resolveChannel(_channel).then(function (channel) {
|
||||||
return _this17.apiRequest("del", _Constants.Endpoints.CHANNEL(channel.id), true).then(function () {
|
return _this18.apiRequest("del", _Constants.Endpoints.CHANNEL(channel.id), true).then(function () {
|
||||||
channel.server.channels.remove(channel);
|
channel.server.channels.remove(channel);
|
||||||
_this17.channels.remove(channel);
|
_this18.channels.remove(channel);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -679,15 +697,15 @@ var InternalClient = (function () {
|
|||||||
// def createRole
|
// def createRole
|
||||||
|
|
||||||
InternalClient.prototype.createRole = function createRole(server, data) {
|
InternalClient.prototype.createRole = function createRole(server, data) {
|
||||||
var _this18 = this;
|
var _this19 = this;
|
||||||
|
|
||||||
server = this.resolver.resolveServer(server);
|
server = this.resolver.resolveServer(server);
|
||||||
|
|
||||||
return this.apiRequest("post", _Constants.Endpoints.SERVER_ROLES(server.id), true).then(function (res) {
|
return this.apiRequest("post", _Constants.Endpoints.SERVER_ROLES(server.id), true).then(function (res) {
|
||||||
var role = server.roles.add(new _StructuresRole2["default"](res, server, _this18.client));
|
var role = server.roles.add(new _StructuresRole2["default"](res, server, _this19.client));
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
return _this18.updateRole(role, data);
|
return _this19.updateRole(role, data);
|
||||||
}
|
}
|
||||||
return role;
|
return role;
|
||||||
});
|
});
|
||||||
@@ -696,7 +714,7 @@ var InternalClient = (function () {
|
|||||||
// def updateRole
|
// def updateRole
|
||||||
|
|
||||||
InternalClient.prototype.updateRole = function updateRole(role, data) {
|
InternalClient.prototype.updateRole = function updateRole(role, data) {
|
||||||
var _this19 = this;
|
var _this20 = this;
|
||||||
|
|
||||||
var server = this.resolver.resolveServer(role.server);
|
var server = this.resolver.resolveServer(role.server);
|
||||||
|
|
||||||
@@ -732,7 +750,7 @@ var InternalClient = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.apiRequest("patch", _Constants.Endpoints.SERVER_ROLES(server.id) + "/" + role.id, true, newData).then(function (res) {
|
return this.apiRequest("patch", _Constants.Endpoints.SERVER_ROLES(server.id) + "/" + role.id, true, newData).then(function (res) {
|
||||||
return server.roles.update(role, new _StructuresRole2["default"](res, server, _this19.client));
|
return server.roles.update(role, new _StructuresRole2["default"](res, server, _this20.client));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -871,7 +889,7 @@ var InternalClient = (function () {
|
|||||||
// def createInvite
|
// def createInvite
|
||||||
|
|
||||||
InternalClient.prototype.createInvite = function createInvite(chanServ, options) {
|
InternalClient.prototype.createInvite = function createInvite(chanServ, options) {
|
||||||
var _this20 = this;
|
var _this21 = this;
|
||||||
|
|
||||||
if (chanServ instanceof _StructuresChannel2["default"]) {
|
if (chanServ instanceof _StructuresChannel2["default"]) {
|
||||||
// do something
|
// do something
|
||||||
@@ -904,7 +922,7 @@ var InternalClient = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.apiRequest("post", epoint, true, options).then(function (res) {
|
return this.apiRequest("post", epoint, true, options).then(function (res) {
|
||||||
return new _StructuresInvite2["default"](res, _this20.channels.get("id", res.channel.id), _this20.client);
|
return new _StructuresInvite2["default"](res, _this21.channels.get("id", res.channel.id), _this21.client);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -921,7 +939,7 @@ var InternalClient = (function () {
|
|||||||
//def getInvite
|
//def getInvite
|
||||||
|
|
||||||
InternalClient.prototype.getInvite = function getInvite(invite) {
|
InternalClient.prototype.getInvite = function getInvite(invite) {
|
||||||
var _this21 = this;
|
var _this22 = this;
|
||||||
|
|
||||||
invite = this.resolver.resolveInviteID(invite);
|
invite = this.resolver.resolveInviteID(invite);
|
||||||
if (!invite) {
|
if (!invite) {
|
||||||
@@ -929,11 +947,11 @@ var InternalClient = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.apiRequest("get", _Constants.Endpoints.INVITE(invite), true).then(function (res) {
|
return this.apiRequest("get", _Constants.Endpoints.INVITE(invite), true).then(function (res) {
|
||||||
if (!_this21.channels.has("id", res.channel.id)) {
|
if (!_this22.channels.has("id", res.channel.id)) {
|
||||||
return new _StructuresInvite2["default"](res, null, _this21.client);
|
return new _StructuresInvite2["default"](res, null, _this22.client);
|
||||||
}
|
}
|
||||||
return _this21.apiRequest("post", _Constants.Endpoints.CHANNEL_INVITES(res.channel.id), true, { validate: invite }).then(function (res2) {
|
return _this22.apiRequest("post", _Constants.Endpoints.CHANNEL_INVITES(res.channel.id), true, { validate: invite }).then(function (res2) {
|
||||||
return new _StructuresInvite2["default"](res2, _this21.channels.get("id", res.channel.id), _this21.client);
|
return new _StructuresInvite2["default"](res2, _this22.channels.get("id", res.channel.id), _this22.client);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -941,7 +959,7 @@ var InternalClient = (function () {
|
|||||||
//def overwritePermissions
|
//def overwritePermissions
|
||||||
|
|
||||||
InternalClient.prototype.overwritePermissions = function overwritePermissions(channel, role, updated) {
|
InternalClient.prototype.overwritePermissions = function overwritePermissions(channel, role, updated) {
|
||||||
var _this22 = this;
|
var _this23 = this;
|
||||||
|
|
||||||
return this.resolver.resolveChannel(channel).then(function (channel) {
|
return this.resolver.resolveChannel(channel).then(function (channel) {
|
||||||
var user;
|
var user;
|
||||||
@@ -982,7 +1000,7 @@ var InternalClient = (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _this22.apiRequest("put", _Constants.Endpoints.CHANNEL_PERMISSIONS(channel.id) + "/" + data.id, true, data);
|
return _this23.apiRequest("put", _Constants.Endpoints.CHANNEL_PERMISSIONS(channel.id) + "/" + data.id, true, data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1018,49 +1036,49 @@ var InternalClient = (function () {
|
|||||||
//def sendTyping
|
//def sendTyping
|
||||||
|
|
||||||
InternalClient.prototype.sendTyping = function sendTyping(channel) {
|
InternalClient.prototype.sendTyping = function sendTyping(channel) {
|
||||||
var _this23 = this;
|
var _this24 = this;
|
||||||
|
|
||||||
return this.resolver.resolveChannel(channel).then(function (channel) {
|
return this.resolver.resolveChannel(channel).then(function (channel) {
|
||||||
return _this23.apiRequest("post", _Constants.Endpoints.CHANNEL(channel.id) + "/typing", true);
|
return _this24.apiRequest("post", _Constants.Endpoints.CHANNEL(channel.id) + "/typing", true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//def startTyping
|
//def startTyping
|
||||||
|
|
||||||
InternalClient.prototype.startTyping = function startTyping(channel) {
|
InternalClient.prototype.startTyping = function startTyping(channel) {
|
||||||
var _this24 = this;
|
var _this25 = this;
|
||||||
|
|
||||||
return this.resolver.resolveChannel(channel).then(function (channel) {
|
return this.resolver.resolveChannel(channel).then(function (channel) {
|
||||||
|
|
||||||
if (_this24.intervals.typing[channel.id]) {
|
if (_this25.intervals.typing[channel.id]) {
|
||||||
// typing interval already exists, leave it alone
|
// typing interval already exists, leave it alone
|
||||||
throw new Error("Already typing in that channel");
|
throw new Error("Already typing in that channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
_this24.intervals.typing[channel.id] = setInterval(function () {
|
_this25.intervals.typing[channel.id] = setInterval(function () {
|
||||||
return _this24.sendTyping(channel)["catch"](function (error) {
|
return _this25.sendTyping(channel)["catch"](function (error) {
|
||||||
return _this24.emit("error", error);
|
return _this25.emit("error", error);
|
||||||
});
|
});
|
||||||
}, 4000);
|
}, 4000);
|
||||||
|
|
||||||
return _this24.sendTyping(channel);
|
return _this25.sendTyping(channel);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//def stopTyping
|
//def stopTyping
|
||||||
|
|
||||||
InternalClient.prototype.stopTyping = function stopTyping(channel) {
|
InternalClient.prototype.stopTyping = function stopTyping(channel) {
|
||||||
var _this25 = this;
|
var _this26 = this;
|
||||||
|
|
||||||
return this.resolver.resolveChannel(channel).then(function (channel) {
|
return this.resolver.resolveChannel(channel).then(function (channel) {
|
||||||
|
|
||||||
if (!_this25.intervals.typing[channel.id]) {
|
if (!_this26.intervals.typing[channel.id]) {
|
||||||
// typing interval doesn"t exist
|
// typing interval doesn"t exist
|
||||||
throw new Error("Not typing in that channel");
|
throw new Error("Not typing in that channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
clearInterval(_this25.intervals.typing[channel.id]);
|
clearInterval(_this26.intervals.typing[channel.id]);
|
||||||
_this25.intervals.typing[channel.id] = false;
|
_this26.intervals.typing[channel.id] = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1091,12 +1109,12 @@ var InternalClient = (function () {
|
|||||||
//def setChannelTopic
|
//def setChannelTopic
|
||||||
|
|
||||||
InternalClient.prototype.setChannelTopic = function setChannelTopic(chann) {
|
InternalClient.prototype.setChannelTopic = function setChannelTopic(chann) {
|
||||||
var _this26 = this;
|
var _this27 = this;
|
||||||
|
|
||||||
var topic = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1];
|
var topic = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||||
return _this26.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
return _this27.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
topic: topic
|
topic: topic
|
||||||
@@ -1109,12 +1127,12 @@ var InternalClient = (function () {
|
|||||||
//def setChannelName
|
//def setChannelName
|
||||||
|
|
||||||
InternalClient.prototype.setChannelName = function setChannelName(chann) {
|
InternalClient.prototype.setChannelName = function setChannelName(chann) {
|
||||||
var _this27 = this;
|
var _this28 = this;
|
||||||
|
|
||||||
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||||
return _this27.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
return _this28.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: name,
|
name: name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
topic: channel.topic
|
topic: channel.topic
|
||||||
@@ -1127,13 +1145,13 @@ var InternalClient = (function () {
|
|||||||
//def setChannelNameAndTopic
|
//def setChannelNameAndTopic
|
||||||
|
|
||||||
InternalClient.prototype.setChannelNameAndTopic = function setChannelNameAndTopic(chann) {
|
InternalClient.prototype.setChannelNameAndTopic = function setChannelNameAndTopic(chann) {
|
||||||
var _this28 = this;
|
var _this29 = this;
|
||||||
|
|
||||||
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
||||||
var topic = arguments.length <= 2 || arguments[2] === undefined ? "" : arguments[2];
|
var topic = arguments.length <= 2 || arguments[2] === undefined ? "" : arguments[2];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||||
return _this28.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
return _this29.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: name,
|
name: name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
topic: topic
|
topic: topic
|
||||||
@@ -1147,12 +1165,12 @@ var InternalClient = (function () {
|
|||||||
//def setTopic
|
//def setTopic
|
||||||
|
|
||||||
InternalClient.prototype.setChannelPosition = function setChannelPosition(chann) {
|
InternalClient.prototype.setChannelPosition = function setChannelPosition(chann) {
|
||||||
var _this29 = this;
|
var _this30 = this;
|
||||||
|
|
||||||
var position = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
|
var position = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||||
return _this29.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
return _this30.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
position: position,
|
position: position,
|
||||||
topic: channel.topic
|
topic: channel.topic
|
||||||
@@ -1280,7 +1298,6 @@ var InternalClient = (function () {
|
|||||||
} else {
|
} else {
|
||||||
client.emit("message", msg);
|
client.emit("message", msg);
|
||||||
}
|
}
|
||||||
self.ack(msg);
|
|
||||||
} else {
|
} else {
|
||||||
client.emit("warn", "message created but channel is not cached");
|
client.emit("warn", "message created but channel is not cached");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ var User = (function (_Equality) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
User.prototype.equalsStrict = function equalsStrict(obj) {
|
User.prototype.equalsStrict = function equalsStrict(obj) {
|
||||||
if (obj instanceof User) return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar && this.status === obj.status && this.game && obj.game && this.game.name === obj.game.name;else return false;
|
if (obj instanceof User) return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar && this.status === obj.status && (this.game === obj.game || this.game && obj.game && this.game.name === obj.game.name);else return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
User.prototype.equals = function equals(obj) {
|
User.prototype.equals = function equals(obj) {
|
||||||
|
|||||||
Reference in New Issue
Block a user