Skip to content

Commit 08b0cdd

Browse files
authored
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.
1 parent 108c20c commit 08b0cdd

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

docs/discord-social-sdk/development-guides/linked-channels.mdx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,67 @@ int main() {
293293
}
294294
```
295295
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+
const uint64_t lobbyId = 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.
330+
[](const discordpp::ClientResult &result, const std::string& inviteUrl) {
331+
if(result.Successful()) {
332+
std::cout << "✅ Discord invite generated successfully!\n";
333+
334+
// On console platforms, you'll need to display the invite URL
335+
// for users to manually navigate to
336+
#ifdef CONSOLE_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.
355+
:::
356+
296357
---
297358
298359
## Next Steps
@@ -323,5 +384,6 @@ int main() {
323384
{/* Autogenerated Reference Links */}
324385
[`Client::GetGuildChannels`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#adba1e5a83c219a9c4f6dab1657778017
325386
[`Client::GetUserGuilds`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#aac1ec02df6074ed9213ce230e6a42fe1
387+
[`Client::JoinLinkedLobbyGuild`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a54ec764e72e168de419ac14e24e8fc60
326388
[`Client::LinkChannelToLobby`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a3114d58d50d4d2cb5752d95e121315d4
327389
[`Client::UnlinkChannelFromLobby`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a28f78a6fe46eb11eb54ee9b53fa94ffe

0 commit comments

Comments
 (0)