Fixed partial user bug

This commit is contained in:
hydrabolt
2015-10-07 20:36:55 +01:00
parent c5d316f0bf
commit 083ed54274
3 changed files with 15 additions and 9 deletions

View File

@@ -1074,6 +1074,12 @@ var Client = (function () {
if (userInCache) {
//user exists
data.user.username = data.user.username || userInCache.username;
data.user.id = data.user.id || userInCache.id;
data.user.discriminator = data.user.discriminator || userInCache.discriminator;
data.user.avatar = data.user.avatar || userInCache.avatar;
var presenceUser = new User(data.user);
if (presenceUser.equalsStrict(userInCache)) {
//they're exactly the same, an actual presence update
@@ -1086,8 +1092,8 @@ var Client = (function () {
});
} else {
//one of their details changed.
self.trigger("userUpdate", userInCache, presenceUser);
self.userCache[self.userCache.indexOf(userInCache)] = presenceUser;
self.trigger("userUpdate", userInCache, presenceUser);
}
}

View File

@@ -983,6 +983,12 @@ class Client {
if (userInCache) {
//user exists
data.user.username = data.user.username || userInCache.username;
data.user.id = data.user.id || userInCache.id;
data.user.discriminator = data.user.discriminator || userInCache.discriminator;
data.user.avatar = data.user.avatar || userInCache.avatar;
var presenceUser = new User(data.user);
if (presenceUser.equalsStrict(userInCache)) {
//they're exactly the same, an actual presence update
@@ -995,8 +1001,8 @@ class Client {
});
} else {
//one of their details changed.
self.trigger("userUpdate", userInCache, presenceUser);
self.userCache[self.userCache.indexOf(userInCache)] = presenceUser;
self.trigger("userUpdate", userInCache, presenceUser);
}
}

View File

@@ -44,7 +44,7 @@ mybot.on("ready", function () {
});
mybot.on("debug", function(info){
console.log(info);
})
mybot.on("unknown", function(info){
@@ -55,12 +55,6 @@ mybot.on("channelUpdate", function(oldChan, newChan){
});
mybot.on("startTyping", function(user, channel){
console.log("start", user);
});
mybot.on("stopTyping", function(user, channel){
console.log("stop", user);
});
function dump(msg) {
console.log(msg);