From b8f54d4b905025fc103d437738d3fa905b1f0853 Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Thu, 4 Sep 2025 17:36:47 +0000 Subject: [PATCH] Add documentation for joining Discord servers via linked lobbies 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. --- .../development-guides/linked-channels.mdx | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/docs/discord-social-sdk/development-guides/linked-channels.mdx b/docs/discord-social-sdk/development-guides/linked-channels.mdx index ac81d09973..183a1493f9 100644 --- a/docs/discord-social-sdk/development-guides/linked-channels.mdx +++ b/docs/discord-social-sdk/development-guides/linked-channels.mdx @@ -293,6 +293,67 @@ int main() { } ``` +## Joining Discord Servers via Linked Lobbies + +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. + +The [`Client::JoinLinkedLobbyGuild`] function generates a one-time-use invite for the current user and on supported +platforms, automatically navigates them to Discord to accept it. + +For example, an in-game player flow could look like: + +1. A Discord server admin links a channel to your game's lobby +2. Players in the lobby see an option to "Join Discord Server" in your game +3. When clicked, the SDK generates a unique invite and opens Discord +4. The player accepts the invite and becomes a Discord server member + +:::info +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. +::: + +```cpp +const uint64_t lobbyId = 1234567890; + +// Invite the user to join the Discord guild associated with the linked lobby +client->JoinLinkedLobbyGuild( + lobbyId, + // This is triggered when the user is using a provisional account, since + // the user needs a real Discord account to join the Discord server, so you don't need + // to implement a provisional user check on implementation. + [] { + // Show a message in your UI explaining that they need to link their Discord account + // and/or step them through the process + std::cout << "📝 User needs to link their Discord account\n"; + }, + // Called after the invite generation attempt completes, providing either a + // successful result with the invite URL or an error if the operation failed. + [](const discordpp::ClientResult &result, const std::string& inviteUrl) { + if(result.Successful()) { + std::cout << "✅ Discord invite generated successfully!\n"; + + // On console platforms, you'll need to display the invite URL + // for users to manually navigate to + #ifdef CONSOLE_PLATFORM + std::cout << "Join the Discord server at: " << inviteUrl << "\n"; + // Display this URL in your game's UI for the player to use + #endif + } else { + std::cerr << "❌ Failed to generate Discord invite\n"; + } + } +); +``` + +### Platform Considerations + +- **Desktop**: The SDK automatically opens the Discord client or web browser with the invite +- **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 + +:::warn +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. +
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. +::: + --- ## Next Steps @@ -323,5 +384,6 @@ int main() { {/* Autogenerated Reference Links */} [`Client::GetGuildChannels`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#adba1e5a83c219a9c4f6dab1657778017 [`Client::GetUserGuilds`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#aac1ec02df6074ed9213ce230e6a42fe1 +[`Client::JoinLinkedLobbyGuild`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a54ec764e72e168de419ac14e24e8fc60 [`Client::LinkChannelToLobby`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a3114d58d50d4d2cb5752d95e121315d4 [`Client::UnlinkChannelFromLobby`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a28f78a6fe46eb11eb54ee9b53fa94ffe \ No newline at end of file