Skip to content

Commit 1692cb3

Browse files
authored
Social SDK: Clarify that Game Invites are powered by Rich Presence (#7747)
Restructure the Game Invites guide to emphasize that invites are not a standalone feature but are entirely powered by Rich Presence configuration. Add clear explanations of the prerequisite Rich Presence setup including party information, join secrets, and/or supported platforms needed to enable invite functionality. This was a point of friction I ran into when onboarding with the Social SDK and creating invites.
1 parent 0e04082 commit 1692cb3

File tree

1 file changed

+76
-47
lines changed

1 file changed

+76
-47
lines changed

docs/discord-social-sdk/development-guides/managing-game-invites.mdx

Lines changed: 76 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,41 @@ import SupportCallout from '../partials/callouts/support.mdx';
1010

1111
## Overview
1212

13-
Game Invites allow users to invite others to join their game session or party. This feature is available on the Discord client and the Social SDK.
13+
Game Invites allow users to invite others to join their game session or party. This feature is available on the
14+
Discord client and the Social SDK.
15+
16+
:::info
17+
**Game Invites are not a standalone feature** - they are **powered entirely by Rich Presence**. When you configure Rich
18+
Presence with party information, a join secret, and/or supported platforms, Discord automatically enables invite
19+
functionality. This guide shows you how to configure Rich Presence to unlock game invites.
20+
:::
1421

1522
### Prerequisites
1623

1724
Before you begin, make sure you have:
1825

26+
- Completed the [Setting Rich Presence](/docs/discord-social-sdk/development-guides/setting-rich-presence) guide
27+
- Understanding that without an active Rich Presence with party data, invites will not work
1928
- Set up the Discord Social SDK with our [Getting Started guide](/docs/discord-social-sdk/getting-started)
20-
- Familiarized yourself with [Setting Rich Presence](/docs/discord-social-sdk/development-guides/setting-rich-presence)
21-
22-
:::info
23-
Let's talk about the naming of some Discord primitives first. Rich Presence, aka "Activity", can be thought of as the "current activity of a user" and is represented by the [`Activity`] class in the SDK and [in our gateway events](/docs/events/gateway-events#activity-object). This is not to be confused with [Discord Activities](/docs/activities/overview), which are embedded games that can also set and display rich presence.
24-
:::
2529

2630
---
2731

28-
## Configuring Game Invites
32+
## Configuring Rich Presence to Enable Game Invites
2933

30-
Game invites, or activity invites, are powered by rich presence.
34+
Game invites, or activity invites, are **powered by rich presence**.
3135

3236
We covered the basics of [Setting Rich Presence](/docs/discord-social-sdk/development-guides/setting-rich-presence) in a previous guide but let's go over the key points again.
3337

38+
:::info
39+
Let's talk about the naming of some Discord primitives first. Rich Presence, aka "Activity", can be thought of as the "current activity of a user" and is represented by the [`Activity`] class in the SDK and [in our gateway events](/docs/events/gateway-events#activity-object). This is not to be confused with [Discord Activities](/docs/activities/overview), which are embedded games that can also set and display rich presence.
40+
:::
41+
3442
### Setting Up Rich Presence
3543

36-
Below is an example of setting up rich presence in your game.
44+
Below is an example of setting up rich presence in your game to be used with game invites.
3745

3846
```cpp
39-
// Create discordpp::Activity
47+
// Create discordpp::Activity - This Rich Presence Activity is your invite configuration
4048
discordpp::Activity activity;
4149
activity.SetType(discordpp::ActivityTypes::Playing);
4250

@@ -48,6 +56,7 @@ activity.SetDetails("Valhalla");
4856
client.UpdateRichPresence(activity, [](discordpp::ClientResult result) {
4957
if(result.Successful()) {
5058
std::cout << "🎮 Rich Presence updated successfully!\n";
59+
// Note: Invites are NOT yet enabled - we need party info and join secret
5160
} else {
5261
std::cerr << "❌ Rich Presence update failed";
5362
}
@@ -63,17 +72,18 @@ You must set up your rich presence [`Activity`] with party information and a joi
6372
```cpp
6473
// rest of the code
6574

66-
// Set the party information
6775
// Create discordpp::ActivityParty
6876
discordpp::ActivityParty party;
6977
party.SetId("party1234");
7078
// current party size
71-
party.SetCurrentSize(1);
79+
party.SetCurrentSize(1);
7280
// max party size
73-
party.SetMaxSize(5);
81+
party.SetMaxSize(5);
82+
// Set the party information in the Activity, to inform the invite about the party size and how many players can join
7483
activity.SetParty(party);
7584

7685
// Update Rich Presence
86+
// Still not enough for invites - we need the join secret!
7787
```
7888

7989
If we run our game, the Discord client will show that we are "In Competitive Match" on "Valhalla" with more information about the party.
@@ -82,7 +92,7 @@ We're almost there! Let's add the join secret next so we can send and receive ga
8292

8393
### Adding Join Secret & Supported Platforms
8494

85-
The last step is to add a join secret to your rich presence activity.
95+
The last step is to add a join secret to your rich presence activity.
8696

8797
The `Join Secret` is a generic secret that you can use to [join a Discord lobby](/docs/discord-social-sdk/development-guides/managing-lobbies), a game session, or something else. The game invite system is a way for players to share this secret value with other players - how you use it is up to you.
8898

@@ -93,20 +103,21 @@ You will also need to set the supported platforms for joining the game so that t
93103

94104
// Create ActivitySecrets
95105
discordpp::ActivitySecrets secrets;
96-
secrets.SetJoin("joinsecret1234");
106+
secrets.SetJoin("joinsecret1234"); // Rich Presence secret will be in the invite payload
97107
activity.SetSecrets(secrets);
98108

99109
// Set supported platforms that can join the game
100110
// See discordpp::ActivityGamePlatforms for available platforms
101111
activity.SetSupportedPlatforms(discordpp::ActivityGamePlatforms::Desktop);
102112

103113
// Update Rich Presence
114+
// ✅ NOW invites are enabled through Rich Presence!
104115
```
105116

106117
### Putting It All Together
107118

108119
```cpp
109-
// Create discordpp::Activity
120+
// Create discordpp::Activity - This Rich Presence Activity is your invite configuration
110121
discordpp::Activity activity;
111122
activity.SetType(discordpp::ActivityTypes::Playing);
112123

@@ -115,18 +126,16 @@ activity.SetState("In Competitive Match");
115126
activity.SetDetails("Valhalla");
116127

117128
// Set the party information
118-
// Create discordpp::ActivityParty
119129
discordpp::ActivityParty party;
120130
party.SetId("party1234");
121-
// current party size
122-
party.SetCurrentSize(1);
123-
// max party size
124-
party.SetMaxSize(5);
131+
party.SetCurrentSize(1); // current party size
132+
party.SetMaxSize(5); // max party size
133+
// Set the party information in the Activity, to inform the invite about the party size and how many players can join
125134
activity.SetParty(party);
126135

127136
// Create ActivitySecrets
128137
discordpp::ActivitySecrets secrets;
129-
secrets.SetJoin("joinsecret1234");
138+
secrets.SetJoin("joinsecret1234"); // Rich Presence secret will be in the invite payload
130139
activity.SetSecrets(secrets);
131140

132141
// Set supported platforms that can join the game
@@ -137,8 +146,10 @@ activity.SetSupportedPlatforms(discordpp::ActivityGamePlatforms::Desktop);
137146
client.UpdateRichPresence(activity, [](discordpp::ClientResult result) {
138147
if(result.Successful()) {
139148
std::cout << "🎮 Rich Presence updated successfully!\n";
149+
// ✅ Rich Presence updated = Game invites now available!
140150
} else {
141151
std::cerr << "❌ Rich Presence update failed";
152+
// ❌ No Rich Presence = No invites possible
142153
}
143154
});
144155
```
@@ -154,11 +165,11 @@ Before we send a game invite, let's make sure that the Discord client knows abou
154165
When a user accepts a game invite for your game within Discord, the Discord client needs to know how to launch the game for that user. We have two ways to do this:
155166

156167
- Register a launch command for your game
157-
- Register a Steam Game ID
168+
- Register a Steam Game ID
158169

159170
For desktop games, you should run one of these commands when the SDK starts up so that if the user tries to join from Discord, the game can be launched for them.
160171

161-
### Registering a Launch Command
172+
### Registering a Launch Command
162173

163174
[`Client::RegisterLaunchCommand`] allows you to register a command that Discord will run to launch your game.
164175

@@ -191,11 +202,19 @@ Users can send game invites directly through the Discord client. This feature is
191202

192203
If a player has the required party, join secret, and supported platforms set in their rich presence, your game can send game invites programmatically through the SDK using [`Client::SendActivityInvite`].
193204

205+
:::warn
206+
[`Client::SendActivityInvite`] only works if Rich Presence is active with proper configuration
207+
:::
208+
194209
```cpp
195210
uint64_t targetUserId = 1111785262289277050;
196211
std::string inviteMessage = "Join my game!";
197212
client->SendActivityInvite(targetUserId, inviteMessage, [](discordpp::ClientResult result) {
198-
std::cout << "Activity Invite sent to user" << std::endl;
213+
if(result.Successful()) {
214+
std::cout << "Activity Invite sent to user" << std::endl;
215+
} else {
216+
std::cerr << "Failed - check if Rich Presence has party, secret, and platforms set" << std::endl;
217+
}
199218
});
200219
```
201220
@@ -205,7 +224,7 @@ client->SendActivityInvite(targetUserId, inviteMessage, [](discordpp::ClientResu
205224
206225
Game invites can also be received in two ways:
207226
208-
1. Users can receive game invites directly through the Discord client.
227+
1. Users can receive game invites directly through the Discord client.
209228
2. Your game can receive game invites for a user programmatically through the SDK.
210229
211230
### Receiving Game Invites in the Discord Client
@@ -219,17 +238,18 @@ Use [`Client::SetActivityInviteCreatedCallback`] to detect new invites and [`Cli
219238
```cpp
220239
client->SetActivityInviteCreatedCallback([&client](discordpp::ActivityInvite invite) {
221240
std::cout << "Activity Invite received from user: " << invite.SenderId() << std::endl;
222-
if(auto message = client->GetMessageHandle(invite.MessageId())){
241+
if(auto message = client->GetMessageHandle(invite.MessageId())){
223242
std::cout << "Invite Message: " << message->Content() << std::endl;
224243
}
225244
client->AcceptActivityInvite(invite, [](discordpp::ClientResult result, std::string joinSecret) {
226245
if(result.Successful()) {
227246
std::cout << "Activity Invite accepted successfully!\n";
247+
// joinSecret comes from the sender's Rich Presence configuration
228248
// Use the joinSecret to connect the two players in your game
229249
} else {
230250
std::cerr << "❌ Activity Invite accept failed";
231251
}
232-
});
252+
});
233253
});
234254
```
235255
---
@@ -239,7 +259,9 @@ client->SetActivityInviteCreatedCallback([&client](discordpp::ActivityInvite inv
239259
Use [`Client::SetActivityJoinCallback`] to monitor for a user accepting a game invite, either in-game or in Discord. Use the join secret to connect the players in your game.
240260

241261
```cpp
262+
// This fires when a user clicks "Join" on someone's Rich Presence
242263
client->SetActivityJoinCallback([&client](std::string joinSecret) {
264+
// joinSecret is pulled from the host's Rich Presence ActivitySecrets
243265
// Use the joinSecret to connect the players in your game
244266
});
245267
```
@@ -274,29 +296,31 @@ Here's a code example of how you might implement this flow:
274296
std::string lobbySecret = "foo"
275297
uint64_t USER_B_ID = 01234567890;
276298
client->CreateOrJoinLobby(lobbySecret, [&client](discordpp::ClientResult result, uint64_t lobbyId) {
277-
// 2. Update rich presence with join secret
299+
// 2. Update Rich Presence with a party and join secret to enable invites
278300
discordpp::Activity activity{};
279301
activity.SetType(discordpp::ActivityTypes::Playing);
280302
activity.SetState("In Lobby");
281303
304+
// Rich Presence party configuration for how many players can join
282305
discordpp::ActivityParty party{};
283306
party.SetId("party1234");
284307
party.SetCurrentSize(1);
285308
party.SetMaxSize(4);
286309
activity.SetParty(party);
287310
288-
// set name, state, party size ...
311+
// Rich Presence secret is what is shared via invites
289312
discordpp::ActivitySecrets secrets{};
290-
secrets.SetJoin(lobbySecret);
313+
secrets.SetJoin(lobbySecret); // This connects Rich Presence to your lobby
291314
activity.SetSecrets(secrets);
292315
316+
// Don't forget to set this Rich Presence update, otherwise SendActivityInvite won't work!
293317
client->UpdateRichPresence(std::move(activity), [&client](discordpp::ClientResult result) {
294-
// 3. Some time later, send an invite
318+
// 3. NOW we can send invites because Rich Presence is configured
295319
client->SendActivityInvite(USER_B_ID, "come play with me", [](discordpp::ClientResult result) {
296320
if(result.Successful()) {
297321
std::cout << "💌 Invite sent successfully!\n";
298322
} else {
299-
std::cerr << "❌ Invite failed\n";
323+
std::cerr << "❌ Invite failed - check Rich Presence configuration\n";
300324
}
301325
});
302326
});
@@ -312,6 +336,7 @@ client->SetActivityInviteCreatedCallback([&client](discordpp::ActivityInvite inv
312336
client->AcceptActivityInvite(invite, [&client](discordpp::ClientResult result, std::string joinSecret) {
313337
if (result.Successful()) {
314338
std::cout << "🎮 Invite accepted! Joining lobby...\n";
339+
// joinSecret came from User A's Rich Presence configuration
315340
316341
// 6. Join the lobby using the joinSecret
317342
client->CreateOrJoinLobby(joinSecret, [=](discordpp::ClientResult result, uint64_t lobbyId) {
@@ -337,21 +362,24 @@ Users can also request to join each other's parties. This code example shows how
337362
std::string lobbySecret = "foo";
338363
uint64_t USER_A_ID = 286438705638408203;
339364
client->CreateOrJoinLobby(lobbySecret, [&client](discordpp::ClientResult result, uint64_t lobbyId) {
340-
// 2. Update rich presence with join secret
365+
// 2. Update Rich Presence with a party and join secret to enable invites
341366
discordpp::Activity activity{};
342367
activity.SetType(discordpp::ActivityTypes::Playing);
343368
activity.SetState("In Lobby");
344369

370+
// Rich Presence party configuration for how many players can join
345371
discordpp::ActivityParty party{};
346372
party.SetId("party1234");
347373
party.SetCurrentSize(1);
348374
party.SetMaxSize(4);
349375
activity.SetParty(party);
350376

351-
// set name, state, party size ...
377+
// Rich Presence secret is what is shared via invites
352378
discordpp::ActivitySecrets secrets{};
353379
secrets.SetJoin(lobbySecret);
354380
activity.SetSecrets(secrets);
381+
382+
// This Rich Presence update is what enables the "Ask to Join" button in Discord
355383
client->UpdateRichPresence(std::move(activity), [&client](discordpp::ClientResult result) {});
356384
});
357385

@@ -377,6 +405,7 @@ client->SetActivityInviteCreatedCallback([&client](discordpp::ActivityInvite inv
377405
client->AcceptActivityInvite(invite, [&client](discordpp::ClientResult result, std::string joinSecret) {
378406
if (result.Successful()) {
379407
std::cout << "🎮 Invite accepted! Joining lobby...\n";
408+
// joinSecret came from User A's Rich Presence
380409
// 5. Join the lobby using the joinSecret
381410
client->CreateOrJoinLobby(joinSecret, [=](discordpp::ClientResult result, uint64_t lobbyId) {
382411
// Successfully joined lobby!
@@ -402,7 +431,7 @@ When a player receives a game invite on mobile, Discord must know how to launch
402431
1. Configure your deep link URL in the Discord Developer Portal:
403432
- Go to your application's `General` tab
404433
- Enter your game's URL scheme (e.g., `yourgame://`)
405-
- Discord will append `/_discord/join?secret=SECRETHERE` to your URL
434+
- Discord will append `/_discord/join?secret=SECRETHERE` to your URL
406435
407436
2. Tell Discord which platforms can accept invites:
408437
```cpp
@@ -417,8 +446,8 @@ activity.SetSupportedPlatforms(
417446

418447
1. The user receives and accepts an invite in Discord
419448
2. Discord launches your game using your URL scheme:
420-
```
421-
yourgame://_discord/join?secret=the_join_secret_you_set
449+
```
450+
yourgame://_discord/join?secret=the_join_secret_you_set
422451
```
423452
3. Your game receives the URL and extracts the join secret
424453
4. Use the secret to connect the player to the session
@@ -428,15 +457,15 @@ activity.SetSupportedPlatforms(
428457
## Next Steps
429458

430459
<Container>
431-
<Card title="Creating a Unified Friends List" link="/docs/discord-social-sdk/development-guides/creating-a-unified-friends-list" icon="ListViewIcon">
432-
Combine Discord and game friends into a single list for easy management.
433-
</Card>
434-
<Card title="Managing Lobbies" link="/docs/discord-social-sdk/development-guides/managing-lobbies" icon="DoorEnterIcon">
435-
Bring players together in a shared lobby with invites, text chat, and voice comms.
436-
</Card>
437-
<Card title="Sending Direct Messages" link="/docs/discord-social-sdk/development-guides/sending-direct-messages" icon="InboxIcon">
438-
Enable private messaging between players.
439-
</Card>
460+
<Card title="Creating a Unified Friends List" link="/docs/discord-social-sdk/development-guides/creating-a-unified-friends-list" icon="ListViewIcon">
461+
Combine Discord and game friends into a single list for easy management.
462+
</Card>
463+
<Card title="Managing Lobbies" link="/docs/discord-social-sdk/development-guides/managing-lobbies" icon="DoorEnterIcon">
464+
Bring players together in a shared lobby with invites, text chat, and voice comms.
465+
</Card>
466+
<Card title="Sending Direct Messages" link="/docs/discord-social-sdk/development-guides/sending-direct-messages" icon="InboxIcon">
467+
Enable private messaging between players.
468+
</Card>
440469
</Container>
441470

442471
<SupportCallout />

0 commit comments

Comments
 (0)