|
1 | 1 | ---
|
2 | 2 | sidebar_label: Setting Rich Presence
|
3 | 3 | ---
|
4 |
| -import PublicClient from '../partials/callouts/public-client.mdx'; |
5 | 4 | import SupportCallout from '../partials/callouts/support.mdx';
|
6 | 5 |
|
7 | 6 | [Home](/docs/intro) > [Discord Social SDK](/docs/discord-social-sdk/overview) > [Development Guides](/docs/discord-social-sdk/development-guides) > {sidebar_label}
|
@@ -198,6 +197,55 @@ activity.SetSupportedPlatforms(discordpp::ActivityGamePlatforms::Desktop);
|
198 | 197 |
|
199 | 198 | See the `ActivityGamePlatforms` enum for all supported platforms.
|
200 | 199 |
|
| 200 | +## Rich Presence Without Authentication |
| 201 | + |
| 202 | +:::warn |
| 203 | +Rich Presence via RPC (Remote Procedure Call) will only work with a running Discord desktop client. It does not support mobile, console or web clients. |
| 204 | +::: |
| 205 | + |
| 206 | +Unlike most other features of the Discord Social SDK, **Rich Presence can be set without authentication**. Instead of |
| 207 | +using [`Client::Connect`] to authenticate with Discord, you can use Rich Presence functionality by directly communicating |
| 208 | +with a running Discord desktop client through RPC (Remote Procedure Call). |
| 209 | + |
| 210 | +### Setting Up Direct Rich Presence |
| 211 | + |
| 212 | +To use Rich Presence without authentication, simply: |
| 213 | + |
| 214 | +1. Set your application ID using [`Client::SetApplicationId`] |
| 215 | +2. Configure your activity details |
| 216 | +3. Call [`Client::UpdateRichPresence`] |
| 217 | + |
| 218 | +```cpp |
| 219 | +auto client = std::make_shared<discordpp::Client>(); |
| 220 | + |
| 221 | +// Set the application ID (no Connect() call needed) |
| 222 | +client->SetApplicationId(APPLICATION_ID); |
| 223 | + |
| 224 | +// Configure rich presence details |
| 225 | +discordpp::Activity activity; |
| 226 | +activity.SetType(discordpp::ActivityTypes::Playing); |
| 227 | +activity.SetState("In Competitive Match"); |
| 228 | +activity.SetDetails("Rank: Diamond II"); |
| 229 | + |
| 230 | +// Update rich presence |
| 231 | +client->UpdateRichPresence( |
| 232 | + activity, [](const discordpp::ClientResult &result) { |
| 233 | + if (result.Successful()) { |
| 234 | + std::cout << "🎮 Rich Presence updated successfully!\n"; |
| 235 | + } else { |
| 236 | + std::cerr << "❌ Rich Presence update failed"; |
| 237 | + } |
| 238 | + }); |
| 239 | +``` |
| 240 | +
|
| 241 | +### Requirements |
| 242 | +
|
| 243 | +* Discord desktop client must be running on the user's machine |
| 244 | +* Your application must be registered with Discord and have a valid Application ID |
| 245 | +
|
| 246 | +This direct approach makes Rich Presence integration much simpler for developers who only need basic presence |
| 247 | +functionality while Discord desktop clients are running. |
| 248 | +
|
201 | 249 | ---
|
202 | 250 |
|
203 | 251 | ## Next Steps
|
@@ -228,4 +276,7 @@ Now that you've set up Rich Presence, you might want to explore:
|
228 | 276 |
|
229 | 277 | {/* Autogenerated Reference Links */}
|
230 | 278 | [`Activity`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Activity.html#ae793d9adbe16fef402b859ba02bee682
|
231 |
| -[`ActivityTypes`]: https://discord.com/developers/docs/social-sdk/namespacediscordpp.html#a6c76a8cbbc9270f025fd6854d5558660 |
| 279 | +[`ActivityTypes`]: https://discord.com/developers/docs/social-sdk/namespacediscordpp.html#a6c76a8cbbc9270f025fd6854d5558660 |
| 280 | +[`Client::Connect`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a873a844c7c4c72e9e693419bb3e290aa |
| 281 | +[`Client::SetApplicationId`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#ad452335c06b28be0406dab824acccc49 |
| 282 | +[`Client::UpdateRichPresence`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#af0a85e30f2b3d8a0b502fd23744ee58e |
0 commit comments