Allow presence updating to allow null games (#1186)

* Adding resetGame functionallity

`setGame` method would allways result in an Object passed to `setPresence`.
Passing { game: null } (supported by discords WebSocket gateway to reset the current Game) to `setPresence` would still result in a Game Object sent to the endpoint.
Explicitly setting `game` to null should overwrite the `game` object provided by `localPresence` or `client.presence`.
This was neither supported by `setGame` or `setPresence`.

* Missing semicolons to resetGame and setPresence

* Fixing trailing spaces, commas and semicolons

* Moving resetGame functionality into setGame method

Minification of if statement in setPresence.
Removing resetGame method and adding a case for `game === null` to setGame method

* Adding missing space in setGame method

* Fix docs
This commit is contained in:
Joschua Schneider
2017-02-22 21:24:39 +01:00
committed by Amish Shah
parent f068010e96
commit 5c2086b351

View File

@@ -186,6 +186,8 @@ class ClientUser extends User {
if (game.url) game.type = 1;
}
if (data.game === null) game = null;
if (typeof data.afk !== 'undefined') afk = data.afk;
afk = Boolean(afk);
@@ -224,11 +226,12 @@ class ClientUser extends User {
/**
* Sets the game the client user is playing.
* @param {string} game Game being played
* @param {?string} game Game being played
* @param {string} [streamingURL] Twitch stream URL
* @returns {Promise<ClientUser>}
*/
setGame(game, streamingURL) {
if (game === null) return this.setPresence({ game });
return this.setPresence({ game: {
name: game,
url: streamingURL,