potential server_member_update bugfix?

This commit is contained in:
hydrabolt
2016-02-13 21:04:47 +00:00
parent 9a57e7ab03
commit 315ae22a7f
7 changed files with 59 additions and 19 deletions

View File

@@ -550,9 +550,9 @@ var Client = (function (_EventEmitter) {
/**
* Client accepts the specified invite to join a server. If the Client is already in the server, the promise/callback resolve immediately.
* @param {InviteResolvable} invite invite to the server
* @param {InviteIDResolvable} invite invite to the server
* @param {function(err: Error, server: Server)} [callback] callback to the method.
* @returns {Promise<Server, Error>} resolves with the newly joined server if succesful, reject with an error if not.
* @returns {Promise<Server, Error>} resolves with the newly joined server if succesful, rejects with an error if not.
* @example
* // join a server - callback
* client.joinServer("https://discord.gg/0BwZcrFhUKZ55bJL", function(err, server){
@@ -573,7 +573,25 @@ var Client = (function (_EventEmitter) {
return this.internal.joinServer(invite).then(dataCallback(callback), errorCallback(callback));
};
// def createServer
/**
* Creates a Discord Server and joins it
* @param {string} name the name of the server
* @param {region} [region=london] the region of the server
* @param {function(err: Error, server: Server)} [callback] callback to the method
* @returns {Promise<Server, Error>} resolves with the newly created server if successful, rejects with an error if not.
* @example
* //creating a server - callback
* client.createServer("discord.js", "london", function(err, server){
* if(err){
* console.log("could not create server");
* }
* });
* @example
* //creating a server - promises
* client.createServer("discord.js", "london")
* .then(server => console.log("Made server!"))
* .catch(error => console.log("Couldn't make server!"));
*/
Client.prototype.createServer = function createServer(name) {
var region = arguments.length <= 1 || arguments[1] === undefined ? "london" : arguments[1];
@@ -582,7 +600,12 @@ var Client = (function (_EventEmitter) {
return this.internal.createServer(name, region).then(dataCallback(callback), errorCallback(callback));
};
// def leaveServer
/**
* Leaves a Discord Server
* @param {ServerResolvable} server the server to leave
* @param {function(err: Error)} [callback] callback to the method
* @returns {Promise<null, Error>} resolves null if successful, otherwise rejects with an error.
*/
Client.prototype.leaveServer = function leaveServer(server) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function () /*err, {}*/{} : arguments[1];
@@ -604,7 +627,12 @@ var Client = (function (_EventEmitter) {
return this.internal.updateServer(server, name, region).then(dataCallback(callback), errorCallback(callback));
};
// def deleteServer
/**
* Leaves a Discord Server, alias to `client.leaveServer`
* @param {ServerResolvable} server the server to leave
* @param {function(err: Error)} [callback] callback to the method
* @returns {Promise<null, Error>} resolves null if successful, otherwise rejects with an error.
*/
Client.prototype.deleteServer = function deleteServer(server) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function () /*err, {}*/{} : arguments[1];

View File

@@ -1637,8 +1637,9 @@ var InternalClient = (function () {
case _Constants.PacketType.SERVER_MEMBER_UPDATE:
var server = self.servers.get("id", data.guild_id);
if (server) {
var user = self.users.get("id", data.user.id);
var user = self.users.add(new _StructuresUser2["default"](data.user, client));
if (user) {
server.memberMap[data.user.id] = server.memberMap[data.user.id] || {};
server.memberMap[data.user.id].roles = data.roles.map(function (pid) {
return server.roles.get("id", pid);
});

View File

@@ -25,6 +25,10 @@
* Resolves supplied data type to something that can be attached to a message. If a String, it can be an URL or a path to a local file.
* @typedef {(String|ReadableStream|Buffer)} FileResolvable
*/
/**
* Resolves supplied data type to an invite ID. If a String, it should be an ID or a direct URL to the invite.
* @typedef {(Invite|String)} InviteIDResolvable
*/
exports.__esModule = true;