Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions docs/discord-social-sdk/development-guides/linked-channels.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<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.
:::

---

## Next Steps
Expand Down Expand Up @@ -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