You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add documentation for joining Discord servers via linked lobbies (#7810)
Documents the JoinLinkedLobbyGuild functionality that allows players
to join Discord servers directly from game lobbies. Includes
platform-specific considerations and security warnings for server
administrators.
Copy file name to clipboardExpand all lines: docs/discord-social-sdk/development-guides/linked-channels.mdx
+62Lines changed: 62 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -293,6 +293,67 @@ int main() {
293
293
}
294
294
```
295
295
296
+
## Joining Discord Servers via Linked Lobbies
297
+
298
+
Once a lobby is linked to a Discord channel, players can join the associated Discord server directly from your game. This feature simplifies the process of getting players into your Discord community by generating invites on-demand, eliminating the need to manually share invite links.
299
+
300
+
The [`Client::JoinLinkedLobbyGuild`] function generates a one-time-use invite for the current user and on supported
301
+
platforms, automatically navigates them to Discord to accept it.
302
+
303
+
For example, an in-game player flow could look like:
304
+
305
+
1. A Discord server admin links a channel to your game's lobby
306
+
2. Players in the lobby see an option to "Join Discord Server" in your game
307
+
3. When clicked, the SDK generates a unique invite and opens Discord
308
+
4. The player accepts the invite and becomes a Discord server member
309
+
310
+
:::info
311
+
Only players with linked Discord accounts can join the server. If a player is using a provisional account, you should prompt them to link their Discord account first.
312
+
:::
313
+
314
+
```cpp
315
+
constuint64_tlobbyId=1234567890;
316
+
317
+
// Invite the user to join the Discord guild associated with the linked lobby
318
+
client->JoinLinkedLobbyGuild(
319
+
lobbyId,
320
+
// This is triggered when the user is using a provisional account, since
321
+
// the user needs a real Discord account to join the Discord server, so you don't need
322
+
// to implement a provisional user check on implementation.
323
+
[] {
324
+
// Show a message in your UI explaining that they need to link their Discord account
325
+
// and/or step them through the process
326
+
std::cout<<"📝 User needs to link their Discord account\n";
327
+
},
328
+
// Called after the invite generation attempt completes, providing either a
329
+
// successful result with the invite URL or an error if the operation failed.
// On console platforms, you'll need to display the invite URL
335
+
// for users to manually navigate to
336
+
#ifdefCONSOLE_PLATFORM
337
+
std::cout<<"Join the Discord server at: "<<inviteUrl<<"\n";
338
+
// Display this URL in your game's UI for the player to use
339
+
#endif
340
+
} else {
341
+
std::cerr<<"❌ Failed to generate Discord invite\n";
342
+
}
343
+
}
344
+
);
345
+
```
346
+
347
+
### Platform Considerations
348
+
349
+
- **Desktop**: The SDK automatically opens the Discord client or web browser with the invite
350
+
- **Console**: Since console platforms cannot navigate to Discord directly, you should display the invite URL in your game's UI so players can use it on another device
351
+
352
+
:::warn
353
+
Discord server admins cannot restrict who can join the server via this method. Any player in a linked lobby can generate an invitation to the server, regardless of their lobby permissions.
354
+
<br/>Make sure to make your players aware to only link channels in servers you trust your players to join, and/or provide in-game options to disable this feature for certain lobbies.
0 commit comments