Change gameID (Deprecated) to game

This commit is contained in:
abalabahaha
2016-01-04 20:46:28 -08:00
parent 69bffc6279
commit 404829a19d
9 changed files with 30 additions and 24 deletions

View File

@@ -44,15 +44,21 @@ status
The status of a user, `String`. Either ``online``, ``offline`` or ``idle``. 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 typing
~~~~~~ ~~~~~~
`Object` containing the following values; `Object` containing the following values:
.. code-block:: js .. code-block:: js

View File

@@ -428,18 +428,18 @@ var Client = (function (_EventEmitter) {
// def setStatus // 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]; var callback = arguments.length <= 2 || arguments[2] === undefined ? function () /*err, {}*/{} : arguments[2];
if (typeof gameID === "function") { if (typeof game === "function") {
// gameID is the callback // game is the callback
callback = gameID; callback = game;
} else if (typeof idleStatus === "function") { } else if (typeof idleStatus === "function") {
// idleStatus is the callback // idleStatus is the callback
callback = idleStatus; 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 // def sendTyping

View File

@@ -1555,8 +1555,8 @@ var InternalClient = (function () {
if (presenceUser.equals(user)) { if (presenceUser.equals(user)) {
// a real presence update // a real presence update
user.status = data.status; user.status = data.status;
user.gameID = data.game_id; user.game = data.game;
client.emit("presence", user, data.status, data.game_id); client.emit("presence", user, data.status, data.game);
} else { } else {
// a name change or avatar change // a name change or avatar change
client.emit("userUpdated", user, presenceUser); client.emit("userUpdated", user, presenceUser);

View File

@@ -112,7 +112,7 @@ var Server = (function (_Equality) {
var user = client.internal.users.get("id", presence.user.id); var user = client.internal.users.get("id", presence.user.id);
if (user) { if (user) {
user.status = presence.status; user.status = presence.status;
user.gameID = presence.game_id; user.game = presence.game;
} }
} }
} }

View File

@@ -31,7 +31,7 @@ var User = (function (_Equality) {
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; this.game = data.game || null;
this.typing = { this.typing = {
since: null, since: null,
channel: null channel: null
@@ -48,7 +48,7 @@ var User = (function (_Equality) {
}; };
User.prototype.equalsStrict = function equalsStrict(obj) { 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) { User.prototype.equals = function equals(obj) {

View File

@@ -350,16 +350,16 @@ export default class Client extends EventEmitter {
} }
// def setStatus // def setStatus
setStatus(idleStatus, gameID, callback = (/*err, {}*/) => { }) { setStatus(idleStatus, game, callback = (/*err, {}*/) => { }) {
if (typeof gameID === "function") { if (typeof game === "function") {
// gameID is the callback // game is the callback
callback = gameID; callback = game;
} else if (typeof idleStatus === "function") { } else if (typeof idleStatus === "function") {
// idleStatus is the callback // idleStatus is the callback
callback = idleStatus; callback = idleStatus;
} }
return this.internal.setStatus(idleStatus, gameID) return this.internal.setStatus(idleStatus, game)
.then(dataCallback(callback), errorCallback(callback)); .then(dataCallback(callback), errorCallback(callback));
} }

View File

@@ -1371,8 +1371,8 @@ export default class InternalClient {
if (presenceUser.equals(user)) { if (presenceUser.equals(user)) {
// a real presence update // a real presence update
user.status = data.status; user.status = data.status;
user.gameID = data.game_id; user.game = data.game;
client.emit("presence", user, data.status, data.game_id); client.emit("presence", user, data.status, data.game);
} else { } else {
// a name change or avatar change // a name change or avatar change

View File

@@ -65,7 +65,7 @@ export default class Server extends Equality {
var user = client.internal.users.get("id", presence.user.id); var user = client.internal.users.get("id", presence.user.id);
if (user) { if (user) {
user.status = presence.status; user.status = presence.status;
user.gameID = presence.game_id; user.game = presence.game;
} }
} }
} }

View File

@@ -13,7 +13,7 @@ export default class User extends Equality{
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; this.game = data.game || null;
this.typing = { this.typing = {
since : null, since : null,
channel : null channel : null
@@ -49,7 +49,7 @@ export default class User extends Equality{
this.discriminator === obj.discriminator && this.discriminator === obj.discriminator &&
this.avatar === obj.avatar && this.avatar === obj.avatar &&
this.status === obj.status && this.status === obj.status &&
this.gameID === obj.gameID (this.game && obj.game && this.game.name === obj.game.name)
); );
else else
return false; return false;