Please describe the problem you are having in as much detail as possible:
If I open a game such as Hearthstone prior to opening Discord, then open Discord, my game status will show as 'playing Hearthstone'.
However if I try to grab this status with member.presence.game (or member.presence.game.name), it will return null (Because I logged into Discord with the game open).
Now, if I were to log into Discord with no game open, then open the game afterward, the status will return an object.
In both instances my status would show "Playing Hearthstone" in Discord, however only one instance returns an object from the API.
This may be a bug, or it may be intentional. I figured I'd bring it to your attention.
Include a reproducible code sample here, if possible:
I unfortunately rolled back my code as what I was doing didn't work, and I've never actually submitted feedback on anything before on GitHub. I apologise.
I basically just looped through the snowflake array and mapped the memberID's, checking each ID's game.name or .game. I then also checked my own status as the control, as listed above the results were consistently reproducable, being that my status will show a game, but will return a null object, if Discord was launched with the game already open.
Further details:
I don't have the chance to test it, but can you ask a friend or go on a second account and see if it still says "Playing Hearthstone"? My guess is it's a client-side thing that can't be resolved by discord.js.
@xDimGG
I don't believe it's a client side issue because I was looking through the snowflake array. Not only did I have my own name to compare to, I also had the hull snowflake. I had a console.log running for each member in the snowflake and their corresponding status. Some returned null, some did not. In the cases where null was returned their status would've been determined to be online due to the conditions I had laid out for it to return a user.
Alright, just got back home and was able to test it out. I launched CS:GO and quit my client. I then connected my bot to the gateway. Obviously, for the guild I was in, since I was offline, I wasn't in the presences field. After that, I launched my Discord client which emitted the PRESENCE_UPDATE event. On my client, it appeared that I was playing CS:GO, but, on the gateway event, game was null. This is an issue with the Discord client and you can learn how to report it here.
Most helpful comment
Alright, just got back home and was able to test it out. I launched CS:GO and quit my client. I then connected my bot to the gateway. Obviously, for the guild I was in, since I was offline, I wasn't in the presences field. After that, I launched my Discord client which emitted the
PRESENCE_UPDATEevent. On my client, it appeared that I was playing CS:GO, but, on the gateway event,gamewas null. This is an issue with the Discord client and you can learn how to report it here.