From 5c2086b351afe85d81d154dd5805e8562296e751 Mon Sep 17 00:00:00 2001 From: Joschua Schneider Date: Wed, 22 Feb 2017 21:24:39 +0100 Subject: [PATCH] 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 --- src/structures/ClientUser.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index 43eddb7c7..98efc4d5c 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -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} */ setGame(game, streamingURL) { + if (game === null) return this.setPresence({ game }); return this.setPresence({ game: { name: game, url: streamingURL,