mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 05:52:05 +00:00
Merge pull request #35 from enebe-nb/master
Private message fixes and gameID
This commit is contained in:
commit
80914b60ec
4 changed files with 24 additions and 6 deletions
|
|
@ -1013,7 +1013,12 @@ var Client = (function () {
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
|
|
||||||
var chann = self.addChannel(data, data.guild_id);
|
var chann;
|
||||||
|
if (data.is_private) {
|
||||||
|
chann = self.addPMChannel(data);
|
||||||
|
} else {
|
||||||
|
chann = self.addChannel(data, data.guild_id);
|
||||||
|
}
|
||||||
var srv = self.getServer("id", data.guild_id);
|
var srv = self.getServer("id", data.guild_id);
|
||||||
if (srv) {
|
if (srv) {
|
||||||
srv.addChannel(chann);
|
srv.addChannel(chann);
|
||||||
|
|
@ -1091,6 +1096,7 @@ var Client = (function () {
|
||||||
gameId: data.game_id
|
gameId: data.game_id
|
||||||
});
|
});
|
||||||
userInCache.status = data.status;
|
userInCache.status = data.status;
|
||||||
|
userInCache.gameId = data.game_id;
|
||||||
} else {
|
} else {
|
||||||
//one of their details changed.
|
//one of their details changed.
|
||||||
self.userCache[self.userCache.indexOf(userInCache)] = presenceUser;
|
self.userCache[self.userCache.indexOf(userInCache)] = presenceUser;
|
||||||
|
|
@ -1288,7 +1294,9 @@ var Client = (function () {
|
||||||
for (var _iterator9 = data.presences[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
|
for (var _iterator9 = data.presences[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
|
||||||
var presence = _step9.value;
|
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) {
|
} catch (err) {
|
||||||
_didIteratorError9 = true;
|
_didIteratorError9 = true;
|
||||||
|
|
@ -1504,7 +1512,7 @@ var Client = (function () {
|
||||||
for (var _iterator14 = self.pmChannelCache[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
|
for (var _iterator14 = self.pmChannelCache[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
|
||||||
var pmc = _step14.value;
|
var pmc = _step14.value;
|
||||||
|
|
||||||
if (pmc.user.equals(destination)) {
|
if (pmc.user && pmc.user.equals(destination)) {
|
||||||
resolve(pmc.id);
|
resolve(pmc.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ var User = (function () {
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
this.avatar = data.avatar;
|
this.avatar = data.avatar;
|
||||||
this.status = data.status || "offline";
|
this.status = data.status || "offline";
|
||||||
|
this.gameId = data.game_id || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// access using user.avatarURL;
|
// access using user.avatarURL;
|
||||||
|
|
|
||||||
|
|
@ -920,7 +920,12 @@ class Client {
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
|
|
||||||
var chann = self.addChannel(data, data.guild_id);
|
var chann;
|
||||||
|
if (data.is_private) {
|
||||||
|
chann = self.addPMChannel(data);
|
||||||
|
} else {
|
||||||
|
chann = self.addChannel(data, data.guild_id);
|
||||||
|
}
|
||||||
var srv = self.getServer("id", data.guild_id);
|
var srv = self.getServer("id", data.guild_id);
|
||||||
if (srv) {
|
if (srv) {
|
||||||
srv.addChannel(chann);
|
srv.addChannel(chann);
|
||||||
|
|
@ -1000,6 +1005,7 @@ class Client {
|
||||||
gameId: data.game_id
|
gameId: data.game_id
|
||||||
});
|
});
|
||||||
userInCache.status = data.status;
|
userInCache.status = data.status;
|
||||||
|
userInCache.gameId = data.game_id;
|
||||||
} else {
|
} else {
|
||||||
//one of their details changed.
|
//one of their details changed.
|
||||||
self.userCache[self.userCache.indexOf(userInCache)] = presenceUser;
|
self.userCache[self.userCache.indexOf(userInCache)] = presenceUser;
|
||||||
|
|
@ -1168,7 +1174,9 @@ class Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var presence of data.presences) {
|
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;
|
return server;
|
||||||
|
|
@ -1265,7 +1273,7 @@ class Client {
|
||||||
|
|
||||||
//check if we have a PM
|
//check if we have a PM
|
||||||
for (var pmc of self.pmChannelCache) {
|
for (var pmc of self.pmChannelCache) {
|
||||||
if (pmc.user.equals(destination)) {
|
if (pmc.user && pmc.user.equals(destination)) {
|
||||||
resolve(pmc.id);
|
resolve(pmc.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ class User{
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
this.avatar = data.avatar;
|
this.avatar = data.avatar;
|
||||||
this.status = data.status || "offline";
|
this.status = data.status || "offline";
|
||||||
|
this.gameId = data.game_id || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// access using user.avatarURL;
|
// access using user.avatarURL;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue