Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.67k stars 3.74k forks source link

Updating "Playing" #1053

Closed Yalnix closed 6 years ago

Yalnix commented 6 years ago

My current playing code looks something like this: await client.change_presence(game=discord.Game(name="GRLC: "+(price_info[0])["price_usd"]), status=discord.Status("online"))

but for whatever reason when this gets processed then it never actually changes on discord.

Rooni commented 6 years ago

Does it happen to be a selfbot?

khazhyk commented 6 years ago

what version are you using?

Gorialis commented 6 years ago

If you're using a standard (OAuth) bot: In August, Discord made a change to presence that required sent presences to include type, even if it was 0. Before v0.16.9 (async) and 1318@b8c1995 (rewrite), no type was sent by default, so when this change happened, presences wouldn't display unless you set a type explicitly. Solution for this would be to update your library.

If you're using a selfbot/userbot: The way presence works for user accounts has changed slightly since it was last directly supported by this library. User accounts never receive their own PRESENCE_UPDATE events, even from other clients, so a presence emitted from one client (such as your desktop Discord client) would not be seen by another (such as your phone). This applies for your bot too, if your selfbot emits a presence, your desktop Discord client won't see it.

However, now, if you play a game on your computer, you can sometimes see the presence from your phone. Why?

Turns out, at some point, Discord made the official client POST to API endpoints when you start playing a game. This only applies to user accounts, and it seems (from testing) that it only relays when the game you're playing is verified.

You could use the Networking tab from within devtools to work out how exactly this flow works, if you're very determined to have your presence relay to other clients. I wouldn't particularly recommend it though, and with the harsher sanctions Discord has been issuing for userbots, I doubt it would be added to this library.

To spare yourself the effort, I'd use an alt account, a bot, or asking another user to determine if your presence has been set correctly, as they will all receive your presence as normal from just the gateway event.

codc3 commented 6 years ago

with me add, listening and watching instead of playing?

Gorialis commented 6 years ago

@pedroricardo Abstracted (user-friendly) extra presence modes aren't in this lib yet (but are planned for rewrite), but as they are just extra Game modes as of current, you can still set them by just using the type kwarg for Game with the respective values:

In future you should probably open a new issue to ask questions like this.

codc3 commented 6 years ago

That's what I was looking for. Thank you.

Yalnix commented 6 years ago

Thanks guys. Issue was that I hadn't explicitly set the type and didn't know it was on the game and not change_presence.