Skip to content

Commit be2047f

Browse files
committed
Social SDK: Clarify that Game Invites are powered by Rich Presence
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 1cb8c26 commit be2047f

File tree

1 file changed

+74
-47
lines changed

1 file changed

+74
-47
lines changed

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

Lines changed: 74 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,39 @@ 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+
Game Invites are not a standalone feature - they are **powered entirely by Rich Presence**. When you configure Rich
17+
Presence with party information, a join secret, and/or supported platforms, Discord automatically enables invite
18+
functionality. This guide shows you how to configure Rich Presence to unlock game invites.
1419

1520
### Prerequisites
1621

1722
Before you begin, make sure you have:
1823

24+
- Completed the [Setting Rich Presence](/docs/discord-social-sdk/development-guides/setting-rich-presence) guide
25+
- Understanding that without an active Rich Presence with party data, invites will not work
1926
- 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-
:::
2527

2628
---
2729

28-
## Configuring Game Invites
30+
## Configuring Rich Presence to Enable Game Invites
2931

30-
Game invites, or activity invites, are powered by rich presence.
32+
Game invites, or activity invites, are **powered by rich presence**.
3133

3234
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.
3335

36+
:::info
37+
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.
38+
:::
39+
3440
### Setting Up Rich Presence
3541

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

3844
```cpp
39-
// Create discordpp::Activity
45+
// Create discordpp::Activity - This Rich Presence Activity is your invite configuration
4046
discordpp::Activity activity;
4147
activity.SetType(discordpp::ActivityTypes::Playing);
4248

@@ -48,6 +54,7 @@ activity.SetDetails("Valhalla");
4854
client.UpdateRichPresence(activity, [](discordpp::ClientResult result) {
4955
if(result.Successful()) {
5056
std::cout << "🎮 Rich Presence updated successfully!\n";
57+
// Note: Invites are NOT yet enabled - we need party info and join secret
5158
} else {
5259
std::cerr << "❌ Rich Presence update failed";
5360
}
@@ -63,17 +70,18 @@ You must set up your rich presence [`Activity`] with party information and a joi
6370
```cpp
6471
// rest of the code
6572

66-
// Set the party information
6773
// Create discordpp::ActivityParty
6874
discordpp::ActivityParty party;
6975
party.SetId("party1234");
7076
// current party size
71-
party.SetCurrentSize(1);
77+
party.SetCurrentSize(1);
7278
// max party size
73-
party.SetMaxSize(5);
79+
party.SetMaxSize(5);
80+
// Set the party information in the Activity, to inform the invite about the party size and how many players can join
7481
activity.SetParty(party);
7582

7683
// Update Rich Presence
84+
// Still not enough for invites - we need the join secret!
7785
```
7886

7987
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 +90,7 @@ We're almost there! Let's add the join secret next so we can send and receive ga
8290

8391
### Adding Join Secret & Supported Platforms
8492

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

8795
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.
8896

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

94102
// Create ActivitySecrets
95103
discordpp::ActivitySecrets secrets;
96-
secrets.SetJoin("joinsecret1234");
104+
secrets.SetJoin("joinsecret1234"); // Rich Presence secret will be in the invite payload
97105
activity.SetSecrets(secrets);
98106

99107
// Set supported platforms that can join the game
100108
// See discordpp::ActivityGamePlatforms for available platforms
101109
activity.SetSupportedPlatforms(discordpp::ActivityGamePlatforms::Desktop);
102110

103111
// Update Rich Presence
112+
// ✅ NOW invites are enabled through Rich Presence!
104113
```
105114

106115
### Putting It All Together
107116

108117
```cpp
109-
// Create discordpp::Activity
118+
// Create discordpp::Activity - This Rich Presence Activity is your invite configuration
110119
discordpp::Activity activity;
111120
activity.SetType(discordpp::ActivityTypes::Playing);
112121

@@ -115,18 +124,16 @@ activity.SetState("In Competitive Match");
115124
activity.SetDetails("Valhalla");
116125

117126
// Set the party information
118-
// Create discordpp::ActivityParty
119127
discordpp::ActivityParty party;
120128
party.SetId("party1234");
121-
// current party size
122-
party.SetCurrentSize(1);
123-
// max party size
124-
party.SetMaxSize(5);
129+
party.SetCurrentSize(1); // current party size
130+
party.SetMaxSize(5); // max party size
131+
// Set the party information in the Activity, to inform the invite about the party size and how many players can join
125132
activity.SetParty(party);
126133

127134
// Create ActivitySecrets
128135
discordpp::ActivitySecrets secrets;
129-
secrets.SetJoin("joinsecret1234");
136+
secrets.SetJoin("joinsecret1234"); // Rich Presence secret will be in the invite payload
130137
activity.SetSecrets(secrets);
131138

132139
// Set supported platforms that can join the game
@@ -137,8 +144,10 @@ activity.SetSupportedPlatforms(discordpp::ActivityGamePlatforms::Desktop);
137144
client.UpdateRichPresence(activity, [](discordpp::ClientResult result) {
138145
if(result.Successful()) {
139146
std::cout << "🎮 Rich Presence updated successfully!\n";
147+
// ✅ Rich Presence updated = Game invites now available!
140148
} else {
141149
std::cerr << "❌ Rich Presence update failed";
150+
// ❌ No Rich Presence = No invites possible
142151
}
143152
});
144153
```
@@ -154,11 +163,11 @@ Before we send a game invite, let's make sure that the Discord client knows abou
154163
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:
155164

156165
- Register a launch command for your game
157-
- Register a Steam Game ID
166+
- Register a Steam Game ID
158167

159168
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.
160169

161-
### Registering a Launch Command
170+
### Registering a Launch Command
162171

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

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

192201
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`].
193202

203+
:::warn
204+
[`Client::SendActivityInvite`] only works if Rich Presence is active with proper configuration
205+
:::
206+
194207
```cpp
195208
uint64_t targetUserId = 1111785262289277050;
196209
std::string inviteMessage = "Join my game!";
197210
client->SendActivityInvite(targetUserId, inviteMessage, [](discordpp::ClientResult result) {
198-
std::cout << "Activity Invite sent to user" << std::endl;
211+
if(result.Successful()) {
212+
std::cout << "Activity Invite sent to user" << std::endl;
213+
} else {
214+
std::cerr << "Failed - check if Rich Presence has party, secret, and platforms set" << std::endl;
215+
}
199216
});
200217
```
201218
@@ -205,7 +222,7 @@ client->SendActivityInvite(targetUserId, inviteMessage, [](discordpp::ClientResu
205222
206223
Game invites can also be received in two ways:
207224
208-
1. Users can receive game invites directly through the Discord client.
225+
1. Users can receive game invites directly through the Discord client.
209226
2. Your game can receive game invites for a user programmatically through the SDK.
210227
211228
### Receiving Game Invites in the Discord Client
@@ -219,17 +236,18 @@ Use [`Client::SetActivityInviteCreatedCallback`] to detect new invites and [`Cli
219236
```cpp
220237
client->SetActivityInviteCreatedCallback([&client](discordpp::ActivityInvite invite) {
221238
std::cout << "Activity Invite received from user: " << invite.SenderId() << std::endl;
222-
if(auto message = client->GetMessageHandle(invite.MessageId())){
239+
if(auto message = client->GetMessageHandle(invite.MessageId())){
223240
std::cout << "Invite Message: " << message->Content() << std::endl;
224241
}
225242
client->AcceptActivityInvite(invite, [](discordpp::ClientResult result, std::string joinSecret) {
226243
if(result.Successful()) {
227244
std::cout << "Activity Invite accepted successfully!\n";
245+
// joinSecret comes from the sender's Rich Presence configuration
228246
// Use the joinSecret to connect the two players in your game
229247
} else {
230248
std::cerr << "❌ Activity Invite accept failed";
231249
}
232-
});
250+
});
233251
});
234252
```
235253
---
@@ -239,7 +257,9 @@ client->SetActivityInviteCreatedCallback([&client](discordpp::ActivityInvite inv
239257
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.
240258

241259
```cpp
260+
// This fires when a user clicks "Join" on someone's Rich Presence
242261
client->SetActivityJoinCallback([&client](std::string joinSecret) {
262+
// joinSecret is pulled from the host's Rich Presence ActivitySecrets
243263
// Use the joinSecret to connect the players in your game
244264
});
245265
```
@@ -274,29 +294,31 @@ Here's a code example of how you might implement this flow:
274294
std::string lobbySecret = "foo"
275295
uint64_t USER_B_ID = 01234567890;
276296
client->CreateOrJoinLobby(lobbySecret, [&client](discordpp::ClientResult result, uint64_t lobbyId) {
277-
// 2. Update rich presence with join secret
297+
// 2. Update Rich Presence with a party and join secret to enable invites
278298
discordpp::Activity activity{};
279299
activity.SetType(discordpp::ActivityTypes::Playing);
280300
activity.SetState("In Lobby");
281301
302+
// Rich Presence party configuration for how many players can join
282303
discordpp::ActivityParty party{};
283304
party.SetId("party1234");
284305
party.SetCurrentSize(1);
285306
party.SetMaxSize(4);
286307
activity.SetParty(party);
287308
288-
// set name, state, party size ...
309+
// Rich Presence secret is what is shared via invites
289310
discordpp::ActivitySecrets secrets{};
290-
secrets.SetJoin(lobbySecret);
311+
secrets.SetJoin(lobbySecret); // This connects Rich Presence to your lobby
291312
activity.SetSecrets(secrets);
292313
314+
// Don't forget to set this Rich Presence update, otherwise SendActivityInvite won't work!
293315
client->UpdateRichPresence(std::move(activity), [&client](discordpp::ClientResult result) {
294-
// 3. Some time later, send an invite
316+
// 3. NOW we can send invites because Rich Presence is configured
295317
client->SendActivityInvite(USER_B_ID, "come play with me", [](discordpp::ClientResult result) {
296318
if(result.Successful()) {
297319
std::cout << "💌 Invite sent successfully!\n";
298320
} else {
299-
std::cerr << "❌ Invite failed\n";
321+
std::cerr << "❌ Invite failed - check Rich Presence configuration\n";
300322
}
301323
});
302324
});
@@ -312,6 +334,7 @@ client->SetActivityInviteCreatedCallback([&client](discordpp::ActivityInvite inv
312334
client->AcceptActivityInvite(invite, [&client](discordpp::ClientResult result, std::string joinSecret) {
313335
if (result.Successful()) {
314336
std::cout << "🎮 Invite accepted! Joining lobby...\n";
337+
// joinSecret came from User A's Rich Presence configuration
315338
316339
// 6. Join the lobby using the joinSecret
317340
client->CreateOrJoinLobby(joinSecret, [=](discordpp::ClientResult result, uint64_t lobbyId) {
@@ -337,21 +360,24 @@ Users can also request to join each other's parties. This code example shows how
337360
std::string lobbySecret = "foo";
338361
uint64_t USER_A_ID = 286438705638408203;
339362
client->CreateOrJoinLobby(lobbySecret, [&client](discordpp::ClientResult result, uint64_t lobbyId) {
340-
// 2. Update rich presence with join secret
363+
// 2. Update Rich Presence with a party and join secret to enable invites
341364
discordpp::Activity activity{};
342365
activity.SetType(discordpp::ActivityTypes::Playing);
343366
activity.SetState("In Lobby");
344367

368+
// Rich Presence party configuration for how many players can join
345369
discordpp::ActivityParty party{};
346370
party.SetId("party1234");
347371
party.SetCurrentSize(1);
348372
party.SetMaxSize(4);
349373
activity.SetParty(party);
350374

351-
// set name, state, party size ...
375+
// Rich Presence secret is what is shared via invites
352376
discordpp::ActivitySecrets secrets{};
353377
secrets.SetJoin(lobbySecret);
354378
activity.SetSecrets(secrets);
379+
380+
// This Rich Presence update is what enables the "Ask to Join" button in Discord
355381
client->UpdateRichPresence(std::move(activity), [&client](discordpp::ClientResult result) {});
356382
});
357383

@@ -377,6 +403,7 @@ client->SetActivityInviteCreatedCallback([&client](discordpp::ActivityInvite inv
377403
client->AcceptActivityInvite(invite, [&client](discordpp::ClientResult result, std::string joinSecret) {
378404
if (result.Successful()) {
379405
std::cout << "🎮 Invite accepted! Joining lobby...\n";
406+
// joinSecret came from User A's Rich Presence
380407
// 5. Join the lobby using the joinSecret
381408
client->CreateOrJoinLobby(joinSecret, [=](discordpp::ClientResult result, uint64_t lobbyId) {
382409
// Successfully joined lobby!
@@ -402,7 +429,7 @@ When a player receives a game invite on mobile, Discord must know how to launch
402429
1. Configure your deep link URL in the Discord Developer Portal:
403430
- Go to your application's `General` tab
404431
- Enter your game's URL scheme (e.g., `yourgame://`)
405-
- Discord will append `/_discord/join?secret=SECRETHERE` to your URL
432+
- Discord will append `/_discord/join?secret=SECRETHERE` to your URL
406433
407434
2. Tell Discord which platforms can accept invites:
408435
```cpp
@@ -417,8 +444,8 @@ activity.SetSupportedPlatforms(
417444

418445
1. The user receives and accepts an invite in Discord
419446
2. Discord launches your game using your URL scheme:
420-
```
421-
yourgame://_discord/join?secret=the_join_secret_you_set
447+
```
448+
yourgame://_discord/join?secret=the_join_secret_you_set
422449
```
423450
3. Your game receives the URL and extracts the join secret
424451
4. Use the secret to connect the player to the session
@@ -428,15 +455,15 @@ activity.SetSupportedPlatforms(
428455
## Next Steps
429456

430457
<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>
458+
<Card title="Creating a Unified Friends List" link="/docs/discord-social-sdk/development-guides/creating-a-unified-friends-list" icon="ListViewIcon">
459+
Combine Discord and game friends into a single list for easy management.
460+
</Card>
461+
<Card title="Managing Lobbies" link="/docs/discord-social-sdk/development-guides/managing-lobbies" icon="DoorEnterIcon">
462+
Bring players together in a shared lobby with invites, text chat, and voice comms.
463+
</Card>
464+
<Card title="Sending Direct Messages" link="/docs/discord-social-sdk/development-guides/sending-direct-messages" icon="InboxIcon">
465+
Enable private messaging between players.
466+
</Card>
440467
</Container>
441468

442469
<SupportCallout />

0 commit comments

Comments
 (0)