Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@giginet
Copy link
Contributor

@giginet giginet commented Jan 3, 2025

Summary

This PR adds platform property to Activity.

When users play games from consoles. The Discord Activity API returns the below response.

{
  "type": 0,
  "timestamps": {
    "start": 1702191977428
  },
  "platform": "ps5",
  "name": "Sonic Superstars",
  "id": "20ac8563beebf2ec",
  "flags": 0,
  "created_at": 1702191977427,
  "assets": {
    "small_image": "mp:external/at5adOeXGcCj4jN9_zB0SiIL3FR8wOxq_d39CDh9Pqo/https/cdn.discordapp.com/assets/playstation-logo-rich-presence.png"
  }
}

According to the documentation, this field is undocumented, but I confirmed this value was returned.

See also the this PR for Discord.py.

@DRSchlaubi
Copy link
Member

Are these documented, if so could we use a "kordenum"

@giginet
Copy link
Contributor Author

giginet commented Jan 3, 2025

Do you mean it should be an enum type to represent each playform?

@DRSchlaubi
Copy link
Member

@giginet
Copy link
Contributor Author

giginet commented Jan 3, 2025

I found an implementation like this.
https://github.com/kyranet/discord-api-types/blob/0aa384ca9a8fe5a35cc4d13f3e2c0b4e5a55c0ca/deno/payloads/v10/gateway.ts#L229

But these platforms are inaccurate, so it's safer to be just a string.

@DRSchlaubi
Copy link
Member

I found an implementation like this. https://github.com/kyranet/discord-api-types/blob/0aa384ca9a8fe5a35cc4d13f3e2c0b4e5a55c0ca/deno/payloads/v10/gateway.ts#L229

But these platforms are inaccurate, so it's safer to be just a string.

Kord enums do have an Unknown type which will be used in the case of an invalid type, however I can't find these type to the be documented anywhere

@giginet
Copy link
Contributor Author

giginet commented Jan 4, 2025

OK, I’ll define the enum values based on this.

@giginet
Copy link
Contributor Author

giginet commented Jan 5, 2025

@DRSchlaubi I defined the known platforms as the Kord Enum.

And I confirmed it works for a known platform or an unknown value.

@lukellmann lukellmann merged commit 446d30c into kordlib:main Jan 5, 2025
2 checks passed
@lukellmann
Copy link
Member

thanks!

@giginet
Copy link
Contributor Author

giginet commented Mar 14, 2025

@lukellmann I’d like to use this feature. Could you release a new version.

@DRSchlaubi
Copy link
Member

You can use the snapshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants