-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding resetGame functionality #1186
Conversation
`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`.
I decided not to extend the existing setGame method, because it accepts two parameters by default. |
// ClientUser#setPresence 181:6
if (data.game === null) game = null;
// ClientUser#setGame
setGame(game, streamingURL) {
if (game === null) return this.setPresence({ game });
return this.setPresence({ game: {
name: game,
url: streamingURL,
} });
} |
Was thinking about that, but for debug readons, if you set a variable myGame for example and gameUrl, if you intend to change the game but your myGame variable is null for some reason, the setGame(name, url) syntax could be misleading. |
that would be your fault, not ours |
I dindn't say its anyones fault 🙂 I get your point, thought alot about the two ways. Having a seperate method for resetting the game might be helpful in a few cases, but if documented not necessary. And its not quite as convenient when setting/resetting the game in a dynamic way. Also the naming is a problem because it does not fit in the I'll push your changes, including the extended Thanks for the feedback! |
Minification of if statement in setPresence. Removing resetGame method and adding a case for `game === null` to setGame method
Just a quick question, I extended the comment above the setGame method like this: Is that format correct? |
No, you'd do |
* 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
* 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
setGame
method would always result in an Object passed tosetPresence
.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 thegame
object provided bylocalPresence
orclient.presence
.This was neither supported by
setGame
orsetPresence
.Discord Documentation: Gateway#gateway-status-update