store gameId on user object

This commit is contained in:
Neto Becker
2015-10-15 11:41:18 -03:00
parent 3578178941
commit 0c5caefa9f
16 changed files with 24 additions and 16 deletions

View File

@@ -179,4 +179,4 @@ var ChannelPermissions = (function () {
return ChannelPermissions;
})();
module.exports = ChannelPermissions;
module.exports = ChannelPermissions;

View File

@@ -1091,6 +1091,7 @@ var Client = (function () {
gameId: data.game_id
});
userInCache.status = data.status;
userInCache.gameId = data.game_id;
} else {
//one of their details changed.
self.userCache[self.userCache.indexOf(userInCache)] = presenceUser;
@@ -1288,7 +1289,9 @@ var Client = (function () {
for (var _iterator9 = data.presences[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
var presence = _step9.value;
self.getUser("id", presence.user.id).status = presence.status;
var user = self.getUser("id", presence.user.id);
user.status = presence.status;
user.gameId = presence.game_id;
}
} catch (err) {
_didIteratorError9 = true;
@@ -1864,4 +1867,4 @@ var Client = (function () {
return Client;
})();
module.exports = Client;
module.exports = Client;

View File

@@ -10,4 +10,4 @@ exports.LOGIN = exports.AUTH + "/login";
exports.LOGOUT = exports.AUTH + "/logout";
exports.USERS = exports.API + "/users";
exports.SERVERS = exports.API + "/guilds";
exports.CHANNELS = exports.API + "/channels";
exports.CHANNELS = exports.API + "/channels";

View File

@@ -169,4 +169,4 @@ var EvaluatedPermissions = (function () {
return EvaluatedPermissions;
})();
module.exports = EvaluatedPermissions;
module.exports = EvaluatedPermissions;

View File

@@ -222,4 +222,4 @@ var Member = (function (_User) {
return Member;
})(User);
module.exports = Member;
module.exports = Member;

View File

@@ -69,4 +69,4 @@ var PMChannel = (function () {
return PMChannel;
})();
module.exports = PMChannel;
module.exports = PMChannel;

View File

@@ -199,4 +199,4 @@ var ServerPermissions = (function () {
return ServerPermissions;
})();
module.exports = ServerPermissions;
module.exports = ServerPermissions;

View File

@@ -149,4 +149,4 @@ var Channel = (function () {
return Channel;
})();
module.exports = Channel;
module.exports = Channel;

View File

@@ -9,4 +9,4 @@ var Discord = {
Client: Client
};
module.exports = Discord;
module.exports = Discord;

View File

@@ -200,4 +200,4 @@ Internal.XHR.setUsername = function (token, avatar, email, newPassword, password
});
};
exports.Internal = Internal;
exports.Internal = Internal;

View File

@@ -32,4 +32,4 @@ var Invite = (function () {
return Invite;
})();
module.exports = Invite;
module.exports = Invite;

View File

@@ -82,4 +82,4 @@ var Message = (function () {
return Message;
})();
module.exports = Message;
module.exports = Message;

View File

@@ -341,4 +341,4 @@ var Server = (function () {
return Server;
})();
module.exports = Server;
module.exports = Server;

View File

@@ -13,6 +13,7 @@ var User = (function () {
this.id = data.id;
this.avatar = data.avatar;
this.status = data.status || "offline";
this.gameId = data.game_id || null;
}
// access using user.avatarURL;
@@ -54,4 +55,4 @@ var User = (function () {
return User;
})();
module.exports = User;
module.exports = User;

View File

@@ -1000,6 +1000,7 @@ class Client {
gameId: data.game_id
});
userInCache.status = data.status;
userInCache.gameId = data.game_id;
} else {
//one of their details changed.
self.userCache[self.userCache.indexOf(userInCache)] = presenceUser;
@@ -1168,7 +1169,9 @@ class Client {
}
for (var presence of data.presences) {
self.getUser("id", presence.user.id).status = presence.status;
var user = self.getUser("id", presence.user.id);
user.status = presence.status;
user.gameId = presence.game_id;
}
return server;

View File

@@ -5,6 +5,7 @@ class User{
this.id = data.id;
this.avatar = data.avatar;
this.status = data.status || "offline";
this.gameId = data.game_id || null;
}
// access using user.avatarURL;