forked from discord/discord-api-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored rich presence documentation into its own section and added…
… docs
- Loading branch information
Showing
13 changed files
with
198 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Rich Presence Best Practices | ||
|
||
Rich Presence is a new feature from Discord that allows you to surface unique, interesting, and actionable data inside a Discord user’s profile when they play your game! This guide is intended to show some best practices on how to make that data the best it can be. It will include images and code samples; for full technical documentation, see our developer documentation. | ||
|
||
If you take away one thing from this guide, let it be this: | ||
|
||
>warn | ||
>Rich Presence data should give others a clear understanding of what someone is doing so they can decide if they want to play together or not. | ||
## Who should use Rich Presence? | ||
|
||
Rich Presence is a powerful way to integrate your game with Discord. To do it most effectively, you should think about its purpose and how well (or not) it matches with your game and your implementation. Rich Presence is designed for these three things: | ||
|
||
1. Show interesting, unique, actionable data in a user’s profile | ||
2. Allow friends to spectate each other’s games | ||
3. Join a friend’s in-game party or server directly from Discord | ||
|
||
We certainly don’t want to stifle creativity, especially for games that can use Rich Presence in an interesting way. However, keep in mind that this sort of gameplay is what it was designed for, and how players will normally interact with it. | ||
|
||
If you want to do something creative, wacky, funky, or otherwise out-there with Rich Presence for your players and aren’t sure if you can, feel free to drop us a line at [[email protected]](mailto:[email protected]). We’re always happy to help! | ||
|
||
## How should you think about the data you show? | ||
|
||
The data in your players’ profiles is the first thing that others on Discord will see about your game, both those familiar with it and those who have never played. It should answer two questions: can I play with my friend right now, and if not, when can I? Show data like: | ||
|
||
- What the player is currently doing | ||
- How much time has elapsed or remains (if applicable) | ||
- Their party state | ||
- Your cool artwork! | ||
|
||
For a great real world example, check out [Holodrive](https://store.steampowered.com/app/370770/Holodrive/) for free on Steam! | ||
|
||
## Tips | ||
|
||
### Keep it Short | ||
|
||
- `details` and `state` should be snippets of data, not sentences. | ||
- Make sure your strings stay on one line—especially on the small profile! | ||
|
||
###### Examples | ||
|
||
| Bad | Good | | ||
|:-----:|:----: | | ||
| ![](rp-long-strings.png) | ![](rp-short-strings.png) | | ||
| The data wraps onto multiple lines. It’s repetitive, slower to read, and messy. | The data all fits on one line per string. Clean! | | ||
|
||
### Make it Actionable! | ||
|
||
- Always keep party size data up to date. | ||
- Keep accurate track of party state: In Queue, In Game, In Menus, etc. | ||
- Include game modes, ranked vs. unranked, etc. so others can clearly see. | ||
|
||
###### Examples | ||
|
||
| Bad | Good | | ||
|:-----:|:----: | | ||
| ![](rp-non-actionable.png) | ![](rp-actionable.png) | | ||
| While Rank 9999 is impressive, it doesn’t present any actionable data for their friends. | This player is in queue for something I want to play. Let's ask to join that open spot! | | ||
|
||
### Use ALL of the fields (where applicable)! | ||
|
||
- Make use of all the fields that are applicable to you. | ||
- Save space by putting map and character names in the tooltips. | ||
- Try not to repeat information. | ||
|
||
###### Examples | ||
|
||
| Bad | Good | | ||
|:-----:|:----: | | ||
| ![](rp-not-all-fields.png) | ![](rp-all-fields.png) | | ||
| The map name takes up space and makes the player's status harder to read at a glance. | Moving the name of the map to the tooltip makes the data cleaner and frees up space for the score. | | ||
|
||
### Have interesting, expressive art! | ||
|
||
- The large image should be consistent for all players in a party. | ||
- The small image is where you can customize on a per-player basis. | ||
- Use high resolution artwork so your art looks great on fancy, high DPI screens. | ||
- We strongly recommend image sizes of 1024x1024. | ||
|
||
###### Examples | ||
|
||
| Bad | Good | | ||
|:-----:|:----: | | ||
| ![](rp-bad-art.png) | ![](rp-good-art.png)| | ||
| The image is dark and unfocused. Highly-detailed images can be hard to see. | This image is bright and matches the details. Let's help! | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Rich Presence FAQ | ||
|
||
Below are answers to some common questions about integrating Rich Presence with your game. If you don't see your question answered here, feel free to reach out to [[email protected]](mailto:[email protected]) for more help. | ||
|
||
#### Q: I don't see any playing status for my game. | ||
|
||
Discord is most likely not automatically detecting the test build for your game because it's running from a directory we aren't looking for. In order to add your test build, go to your user settings in Discord, then to the "Games" subsection, click "Add it!", and select your process from the drop-down list. | ||
|
||
#### Q: I see "Playing MyGame", but no Rich Presence data. | ||
|
||
There's a couple things that could be going on: | ||
|
||
- If you're running two instances of the Discord client, check both! | ||
- Double check that your `Discord_Initialize()` function is correct. | ||
|
||
Throughout development, make sure you have your `errored()` and `disconnected()` callbacks hooked up for debugging. You can open up the console in Discord and look for errors pertaining to `SET_ACTIVITY` for more information as well. | ||
|
||
#### Q: I'm not seeing Spectate or Ask to Join buttons on my profile. | ||
|
||
Make sure you applied for approval! If you want these buttons on your players' profiles, we require your integration to go through an approval process. If you have applied and have been approved and still don't see the buttons, check your Discord console for errors. | ||
|
||
#### Q: What happens if someone has more than one game running that supports Rich Presence? | ||
|
||
Discord will show presence for whichever game is currently focused or was most recently focused. | ||
|
||
#### Q: What if someone looking at my profile or an invite doesn't own the game? | ||
|
||
Anyone can see your profile data, whether they own the game or not. They'll only be able to interact with chat invites or profile buttons if they own the game and have launched it at least once. Otherwise, the invite/button tooltip will show "Game Not Detected". | ||
|
||
#### Q: Do join invitations allow players to select the number of open slots? | ||
|
||
Currently, the SDK does not support this. Party slot information is determined by the party data you sent in your presence payload. | ||
|
||
#### Q: Can I send images via the payload rather than uploading them to my Developer Dashboard? | ||
|
||
Unfortunately, the SDK does not support this feature right now. However, we hear your desires! We know that a lot of games, like customization-heavy RPGs, would benefit greatly from being able to programmatically upload assets. It may be something we tackle in the future. | ||
|
||
#### Q: Can I change something in the SDK for my own purposes? | ||
|
||
Go nuts! The SDK is open source by design. If you need or want to change something for the purposes of your specific integration—like changing our JSON parser, or changing all of the variable names to the names of your pets—go ahead and tinker to your heart's content. | ||
|
||
#### Q: OK—I've got it working! Now, how do I make my integration look _awesome_? | ||
|
||
I'm happy ~~we preempted your question~~ you asked! Check out our [Rich Presence Best Practices](#DOCS_BEST_PRACTICES/) guide for a rundown on how to make your integration the best that it can be! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
# Introducing Rich Presence | ||
|
||
>danger | ||
>Rich Presence is live! If you are testing a game integration with Rich Presence, other users will be able to see it. Please create a private test account and do not join any public servers while testing your integration. | ||
How easy is it for people to play your game together? With Rich Presence from Discord—a new feature in the ever-expanding GameBridge suite—it just got so easy, a ~~caveman~~ Junior Dev could do it. | ||
|
||
Rich Presence is currently in a private alpha phase intended for game integrations and not yet ready for general public access. If you are a game developer interested in getting early access, mention Rich Presence in an [application to our Gamebridge program](https://discordapp.com/gamebridge) and we'll keep it in mind when we review your application. | ||
Rich Presence is now **live**! If you are testing a game integration with Rich Presence, other users will be able to see it. Please create a private test account and do not join any public servers while testing your integration. | ||
|
||
>info | ||
>If you want to stay up to date with the latest developer news from Discord and learn about new and exciting ways to work with us, sign up for our [developer newsletter](https://discordapp.com/dev-newsletter). | ||
## So, what is it? | ||
|
||
Rich Presence allows you to leverage the totally overhauled "Now Playing" section in a Discord user's profile to help people play your game together. Rich game data—including duration, score, current boss or map, and so much more—lives inside Discord. You can spectate a friend's game directly from their profile popout, or party up via beautiful chat embeds with real-time information about open party slots and the party's in-game status. No more exchanging usernames and friend codes, or wondering if there's room for you to join. Rich Presence is a living invitation to play together, or to watch your friends kick butt. | ||
|
||
## Step 0: Get the SDK | ||
|
||
You've decided you want to integrate with Rich Presence. Of course you did! It's awesome—just ask us. You can get the SDK from our [GitHub repository](https://github.com/discordapp/discord-rpc). Grab a release build or use our build scripts, and check out the examples while you're there! We support C, C++, Unity, and Unreal Engine out of the box. If we don't have a release type that fits your development needs, roll your own! It's all open-source. | ||
|
||
## So, how does it work? | ||
|
||
We worked hard to make using Discord's Rich Presence system as easy as possible. All you need is our header file—what you will interact with—and our library—where we did all the hard work for you—and you are ready to roll! | ||
|
@@ -51,6 +55,8 @@ void InitDiscord() | |
} | ||
``` | ||
|
||
When you are ready to publish your integration, we recommend digging into the source code of the SDK and copying `discord_register.h`, `discord_register_win.cpp`, `discord_register_osx.m`, and `discord_register_linux.cpp` into your installation and update process. By registering your application protocols on installation and update, your players won't need to run the game before being able to interact with invites, Ask to Join, and spectating in Discord. | ||
|
||
## Updating Presence | ||
|
||
The core of Discord's Rich Presence SDK is the `Discord_UpdatePresence()` function. This is what sends your game data up to Discord to be seen and used by others. You should call `Discord_UpdatePresence()` any time something important in the presence payload changes. Here's an example: | ||
|
@@ -60,12 +66,17 @@ The core of Discord's Rich Presence SDK is the `Discord_UpdatePresence()` functi | |
```c | ||
void UpdatePresence() | ||
{ | ||
char buffer[256]; | ||
DiscordRichPresence discordPresence; | ||
memset(&discordPresence, 0, sizeof(discordPresence)); | ||
discordPresence.state = "In a Group"; | ||
discordPresence.details = "Competitive | In a Match"; | ||
discordPresence.endTimestamp = time(nullptr) + ((60 * 5) + 23); | ||
sprintf(buffer, "Ranked | Mode: %d", GameEngine.GetMode()); | ||
discordPresence.details = buffer; | ||
discordPresence.endTimestamp = time(0) + 5 * 60; | ||
discordPresence.largeImageKey = "canary-large"; | ||
discordPresence.smallImageKey = "ptb-small"; | ||
discordPresence.partyId = GameEngine.GetPartyId(); | ||
discordPresence.partySize = 3; | ||
discordPresence.partySize = 1; | ||
discordPresence.partyMax = 6; | ||
discordPresence.matchSecret = "4b2fdce12f639de8bfa7e3591b71a0d679d7c93f"; | ||
discordPresence.spectateSecret = "e7eb30d2ee025ed05c71ea495f770b76454ee4e0"; | ||
|
@@ -116,10 +127,6 @@ typedef struct DiscordRichPresence { | |
| joinSecret | char* | unique hased string for chat invitations and Ask to Join | MTI4NzM0OjFpMmhuZToxMjMxMjM= | | ||
| instance | int8_t | helps track when games have ended | 1 | | ||
|
||
Below is an image that shows which fields go where when sending a full data payload with spectating and notifications enabled; use it for reference for your own data: | ||
|
||
![](rp-profile-view.png) | ||
|
||
## Joining | ||
|
||
#### Relevant Callbacks: | ||
|
@@ -241,7 +248,7 @@ OK, well, not entirely. But! Discord _will_ host any and all artwork that you ne | |
>warn | ||
>**Asset keys are automatically normalized to lowercase**. Be mindful of this when referring to them in your code. | ||
## A final note on testing and Game Detection | ||
## A note on testing and Game Detection | ||
|
||
In order to test your Rich Presence integration locally, you and your testers will need to make sure that your game client is detected by Discord. If your game is not automatically detected, presence data will not be shown. To detect your game, go to User Settings -> Games -> Add it! and select your application from the dropdown list. Every user working with your local development build will need to follow these steps in order for Discord to detect their presence. | ||
|
||
|
@@ -250,3 +257,7 @@ If you don't see Rich Presence data in your profile while testing, make sure you | |
If you are having issues with your release build not being detected, send us an email at [[email protected]](mailto:[email protected]) and we'll add it to our database for you. | ||
|
||
If you're testing on your own, we recommend [downloading two separate release channels](https://discordapp.com/download) of the Discord desktop client. You can log into the stable, public test, and canary builds with separate credentials, making testing easier for a single developer. | ||
|
||
## So, what now? | ||
|
||
Get to coding! We can't wait to see the awesome integration you come up with. If you need some quick questions answered, look no further than our [Rich Presence FAQ](#DOCS_FAQ/). If you want to know how to make your integration the best it can be, read our [Best Practices Guide](#DOCS_BEST_PRACTICES/). If you're ready to release, consult our [Launch Checklist](#DOCS_LAUNCH_CHECKLIST/) and make sure you haven't missed anything! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Rich Presence Launch Checklist | ||
|
||
Ready to launch a Rich Presence integration for your game? Did you read our [Best Practices](#DOCS_BEST_PRACTICES/) guide? If so, we recommend looking over this checklist one last time to ensure that your integration is as great as it can be! | ||
|
||
#### Profile Strings | ||
|
||
- Have you made use of all available fields where appropriate? | ||
- Do your strings fit on their own lines without line wrapping? | ||
- Did you check on the smaller profile pop out? | ||
- Do they clearly communicate: | ||
- What the player is currently doing? | ||
- If the player is in a group or playing alone? | ||
- If the player is in a state where they can party up? | ||
|
||
#### Artwork | ||
|
||
- Is your artwork high resolution? | ||
- Are your image sizes at least 1024x1024? | ||
- Is it clean, interesting, and descriptive without being too highly detailed? | ||
- Do you have artwork for every different state? Don't forget your default state/main menu! | ||
- Did you make use of tooltips and the small image where appropriate? | ||
|
||
#### Joining | ||
|
||
>warn | ||
>If you need the Ask to Join button on users' profiles, remember to email us at [[email protected]](mailto:[email protected]) for whitelisting and approval! | ||
- Have you successfully implemented join invites for your game if applicable? | ||
- Does the state of the invite properly represent the party/group in-game with regards to: | ||
- Size? | ||
- Open slots? | ||
- Discord _and_ non-Discord users in the party? | ||
- Are you able to post invites to Discord without any additional in-game setup or configuration? | ||
- Are you properly removing data from the presence payload when someone can no longer send invites? | ||
- A `joinSecret` should not be sent if the player can't invite anyone! | ||
|
||
#### Spectating | ||
|
||
>warn | ||
>If you need the Spectate button on users' profiles, remember to email us at [[email protected]](mailto:[email protected]) for whitelisting and approval! | ||
- Have you successfully implemented spectate invites for your game if applicable? | ||
- Is your game's spectate mode true spectating? | ||
- We do _not_ allow using the Spectate button as a pseudo-Join button. | ||
- Are you properly removing data from the presence payload when someone can no longer spectate? | ||
- A `spectateSecret` should not be sent if the player can't be spectated! |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.