From 404829a19d0b23aa22fdaf83fe199f21ba9897e9 Mon Sep 17 00:00:00 2001 From: abalabahaha Date: Mon, 4 Jan 2016 20:46:28 -0800 Subject: [PATCH] Change gameID (Deprecated) to game --- docs/docs_user.rst | 14 ++++++++++---- lib/Client/Client.js | 10 +++++----- lib/Client/InternalClient.js | 4 ++-- lib/Structures/Server.js | 2 +- lib/Structures/User.js | 4 ++-- src/Client/Client.js | 10 +++++----- src/Client/InternalClient.js | 4 ++-- src/Structures/Server.js | 2 +- src/Structures/User.js | 4 ++-- 9 files changed, 30 insertions(+), 24 deletions(-) diff --git a/docs/docs_user.rst b/docs/docs_user.rst index 6702618b4..815f81fd7 100644 --- a/docs/docs_user.rst +++ b/docs/docs_user.rst @@ -44,15 +44,21 @@ status The status of a user, `String`. Either ``online``, ``offline`` or ``idle``. -gameID -~~~~~~ +game +~~~~ -The ID of the game a user is playing, `Number`. +The game object of a user. `null` if not playing a game, otherwise `Object` containing the following values: + +.. code-block:: js + + { + name : 'Game Name' //Name of game user is playing + } typing ~~~~~~ -`Object` containing the following values; +`Object` containing the following values: .. code-block:: js diff --git a/lib/Client/Client.js b/lib/Client/Client.js index d3dd49b01..b25237753 100644 --- a/lib/Client/Client.js +++ b/lib/Client/Client.js @@ -428,18 +428,18 @@ var Client = (function (_EventEmitter) { // def setStatus - Client.prototype.setStatus = function setStatus(idleStatus, gameID) { + Client.prototype.setStatus = function setStatus(idleStatus, game) { var callback = arguments.length <= 2 || arguments[2] === undefined ? function () /*err, {}*/{} : arguments[2]; - if (typeof gameID === "function") { - // gameID is the callback - callback = gameID; + if (typeof game === "function") { + // game is the callback + callback = game; } else if (typeof idleStatus === "function") { // idleStatus is the callback callback = idleStatus; } - return this.internal.setStatus(idleStatus, gameID).then(dataCallback(callback), errorCallback(callback)); + return this.internal.setStatus(idleStatus, game).then(dataCallback(callback), errorCallback(callback)); }; // def sendTyping diff --git a/lib/Client/InternalClient.js b/lib/Client/InternalClient.js index dc55d9810..0561334e4 100644 --- a/lib/Client/InternalClient.js +++ b/lib/Client/InternalClient.js @@ -1555,8 +1555,8 @@ var InternalClient = (function () { if (presenceUser.equals(user)) { // a real presence update user.status = data.status; - user.gameID = data.game_id; - client.emit("presence", user, data.status, data.game_id); + user.game = data.game; + client.emit("presence", user, data.status, data.game); } else { // a name change or avatar change client.emit("userUpdated", user, presenceUser); diff --git a/lib/Structures/Server.js b/lib/Structures/Server.js index 180fd98f7..519000fd2 100644 --- a/lib/Structures/Server.js +++ b/lib/Structures/Server.js @@ -112,7 +112,7 @@ var Server = (function (_Equality) { var user = client.internal.users.get("id", presence.user.id); if (user) { user.status = presence.status; - user.gameID = presence.game_id; + user.game = presence.game; } } } diff --git a/lib/Structures/User.js b/lib/Structures/User.js index 685ab6b49..3dc1ee0b8 100644 --- a/lib/Structures/User.js +++ b/lib/Structures/User.js @@ -31,7 +31,7 @@ var User = (function (_Equality) { this.id = data.id; this.avatar = data.avatar; this.status = data.status || "offline"; - this.gameID = data.game_id || null; + this.game = data.game || null; this.typing = { since: null, channel: null @@ -48,7 +48,7 @@ var User = (function (_Equality) { }; 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.gameID === obj.gameID;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.name === obj.game.name;else return false; }; User.prototype.equals = function equals(obj) { diff --git a/src/Client/Client.js b/src/Client/Client.js index 347d98318..9b016562b 100644 --- a/src/Client/Client.js +++ b/src/Client/Client.js @@ -350,16 +350,16 @@ export default class Client extends EventEmitter { } // def setStatus - setStatus(idleStatus, gameID, callback = (/*err, {}*/) => { }) { - if (typeof gameID === "function") { - // gameID is the callback - callback = gameID; + setStatus(idleStatus, game, callback = (/*err, {}*/) => { }) { + if (typeof game === "function") { + // game is the callback + callback = game; } else if (typeof idleStatus === "function") { // idleStatus is the callback callback = idleStatus; } - return this.internal.setStatus(idleStatus, gameID) + return this.internal.setStatus(idleStatus, game) .then(dataCallback(callback), errorCallback(callback)); } diff --git a/src/Client/InternalClient.js b/src/Client/InternalClient.js index 81ef3bcdf..16842432a 100644 --- a/src/Client/InternalClient.js +++ b/src/Client/InternalClient.js @@ -1371,8 +1371,8 @@ export default class InternalClient { if (presenceUser.equals(user)) { // a real presence update user.status = data.status; - user.gameID = data.game_id; - client.emit("presence", user, data.status, data.game_id); + user.game = data.game; + client.emit("presence", user, data.status, data.game); } else { // a name change or avatar change diff --git a/src/Structures/Server.js b/src/Structures/Server.js index b3e46d0d3..93688d2d2 100644 --- a/src/Structures/Server.js +++ b/src/Structures/Server.js @@ -65,7 +65,7 @@ export default class Server extends Equality { var user = client.internal.users.get("id", presence.user.id); if (user) { user.status = presence.status; - user.gameID = presence.game_id; + user.game = presence.game; } } } diff --git a/src/Structures/User.js b/src/Structures/User.js index 732293d85..b3751c774 100644 --- a/src/Structures/User.js +++ b/src/Structures/User.js @@ -13,7 +13,7 @@ export default class User extends Equality{ this.id = data.id; this.avatar = data.avatar; this.status = data.status || "offline"; - this.gameID = data.game_id || null; + this.game = data.game || null; this.typing = { since : null, channel : null @@ -49,7 +49,7 @@ export default class User extends Equality{ this.discriminator === obj.discriminator && this.avatar === obj.avatar && this.status === obj.status && - this.gameID === obj.gameID + (this.game && obj.game && this.game.name === obj.game.name) ); else return false;