### Integrate Discord Social SDK in Standalone iOS C++ Project Source: https://discord.com/developers/docs/social-sdk/index.html/md_pages_2mobile This snippet provides a step-by-step guide for integrating the Discord Social SDK as a C++ library into a standard iOS project. It covers adding the framework, configuring build settings, enabling background audio, registering URL schemes, and initializing the SDK. ```C++ 1. Create an Objective-C iOS project. 2. Add 'discord_partner_sdk.xcframework' to your project. 3. In Build Phases -> Link Binary with Libraries, ensure 'discord_partner_sdk.xcframework' is linked. 4. In the General tab, under Frameworks, Libraries and Embedded Content, set 'discord_partner_sdk.xcframework' to 'Embed & Sign'. 5. To maintain voice connectivity while backgrounded, set background audio modes in your 'Info.plist' using the Signing & Capabilities tab. Select 'Audio, AirPlay, and Picture in Picture'. 6. To enable 'discordpp::Client::Authorize()' support, register the URL scheme 'discord-YOURAPPID' (e.g., 'discord-123456') in your 'Info.plist'. 7. Include headers in a C++ or ObjC++ (.mm) source file: #include // In exactly one file, define before including: #define DISCORDPP_IMPLEMENTATION 8. In your main game loop, call 'discordpp::RunCallbacks()'. ``` -------------------------------- ### Configure Discord Overlay for In-Game OAuth2 (Windows) Source: https://discord.com/developers/docs/social-sdk/index.html/authentication This guide explains how to enable and verify the Discord overlay for in-game OAuth2 modals on Windows. It covers manual setup for testing, the process for official launch verification, and the use of `discordpp::Client::SetGameWindowPid` for games with main windows in different processes. ```Conceptual Overlay Configuration (Windows Only): - For testing: Manually add game and enable overlay in Discord Settings -> Games. - For launch: Discord verification required to enable overlay by default for users. - Multi-process games: Set main window PID using `discordpp::Client::SetGameWindowPid`. ``` ```APIDOC Method: discordpp::Client::SetGameWindowPid Description: When users are linking their account with Discord, which involves an OAuth2 flow, the SDK can streamline the process by setting the game window PID. This helps the SDK to correctly display the OAuth2 modal in-game, especially when the game's main window is not in the same process as the Discord integration. ``` -------------------------------- ### Integrate Discord Social SDK into Android C++ Game Project Source: https://discord.com/developers/docs/social-sdk/index.html/md_pages_2mobile This guide provides step-by-step instructions for integrating the Discord Social SDK into an Android game developed with C++. It covers adding the SDK as a Gradle dependency, configuring CMake for native linking, including necessary C++ headers, and initializing the SDK within the Android activity lifecycle to enable Discord features in your game. ```Gradle implementation files("libs/discord_partner_sdk.aar") ``` ```CMake find_package(discord_partner_sdk REQUIRED CONFIG) ``` ```CMake target_link_libraries(your_target discord_partner_sdk::discord_partner_sdk) ``` ```C++ #include "discordpp.h" ``` ```C++ #define DISCORDPP_IMPLEMENTATION\n#include "discordpp.h" ``` ```Java com.discord.socialsdk.DiscordSocialSdkInit.setEngineActivity(this); ``` ```C++ discordpp::RunCallbacks(); ``` -------------------------------- ### APIDOC: discordpp::Client::Authorize() Method and Android Integration Source: https://discord.com/developers/docs/social-sdk/index.html/md_pages_2mobile This section details the `discordpp::Client::Authorize()` method, which initiates an OAuth2 flow for user sign-in with Discord. It also outlines the necessary Android-specific steps, including adding the `androidx.browser` dependency and configuring `AndroidManifest.xml` for proper OAuth2 redirect handling. ```Gradle implementation "androidx.browser:browser:1.8.0" ``` ```APIDOC Method: `discordpp::Client::Authorize()`\nDescription: Initiates an OAuth2 flow for a user to "sign in with Discord". This flow is intended for desktop and mobile applications.\nRequired AndroidManifest.xml Configuration: Refer to SDK documentation for specific activity registration details. ``` -------------------------------- ### C++ Discord Social SDK Lobby Invite Implementation Example Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1Activity This C++ code example illustrates the complete process of handling Discord game invites, from the perspective of both the inviter (User A) and the invitee (User B). It demonstrates creating a lobby, updating rich presence with a join secret, sending an invite, monitoring for invites, and accepting an invite to join a lobby. ```C++ // User A // 1. Create a lobby with secret std::string lobbySecret = "foo"; client->CreateOrJoinLobby(lobbySecret, [=](discordpp::ClientResult result, uint64_t lobbyId) { // 2. Update rich presence with join secret discordpp::Activity activity{}; // set name, state, party size ... discordpp::ActivitySecrets secrets{}; secrets.SetJoin(lobbySecret); activity.SetSecrets(secrets); client->UpdateRichPresence(std::move(activity), [](discordpp::ClientResult result) {}); }); // 3. Some time later, send an invite client->SendActivityInvite(USER_B_ID, "come play with me", [](auto result) {}); // User B // 4. Monitor for new invites. Alternatively, you can use // Client::SetActivityInviteUpdatedCallback to get updates on existing invites. client->SetActivityInviteCreatedCallback([client](auto invite) { // 5. When an invite is received, ask the user if they want to accept it. // If they choose to do so then go ahead and invoke AcceptActivityInvite client->AcceptActivityInvite(invite, [client](discordpp::ClientResult result, std::string secret) { if (result.Successful()) { // 5. Join the lobby using the joinSecret client->CreateOrJoinLobby(secret, [](discordpp::ClientResult result, uint64_t lobbyId) { // Successfully joined lobby! }); } }); }); ``` -------------------------------- ### Configure Discord Social SDK for Unity iOS Source: https://discord.com/developers/docs/social-sdk/index.html/md_pages_2mobile This snippet details the mobile-specific configurations required for Unity iOS projects to enable Discord Social SDK features like OAuth2 authorization and voice support. It outlines steps for URL scheme setup, microphone usage description, and background audio modes. ```Unity - Configure OAuth2 Authorize support: - Open Project Settings -> Player -> iOS tab -> Other Settings. - Locate 'Supported URL Schemes' and add 'discord-' (e.g., 'discord-123456'). - Enable voice support: - Set 'Microphone Usage Description' to a valid string in Player Settings. - Enable background voice support: - Edit 'Info.plist' to enable appropriate background modes. - A build postprocessor (e.g., 'Assets/Scripts/Editor/VoicePostBuildProcessor.cs') can assist. ``` -------------------------------- ### APIDOC: discordpp::Client::Authorize() Method Source: https://discord.com/developers/docs/social-sdk/index.html/md_pages_2mobile This API documentation describes the 'Authorize' method of the 'discordpp::Client' class, which initiates an OAuth2 flow for user authentication. It is designed for both desktop and mobile applications and requires specific URL scheme configurations on mobile platforms. ```APIDOC Class: discordpp::Client Method: Authorize() Description: Initiates an OAuth2 flow for a user to "sign in with Discord". This flow is intended for desktop and mobile applications. Parameters: None explicitly listed in source. Return Type: Not specified in source. Notes: Requires callback URL scheme configuration on iOS (discord-) and Android (custom URL scheme activity). ``` -------------------------------- ### Configure Discord Social SDK for Unity Android Source: https://discord.com/developers/docs/social-sdk/index.html/md_pages_2mobile This snippet outlines the necessary configurations for Unity Android projects to support Discord Social SDK features, specifically focusing on the OAuth2 authorization flow. It covers manifest modifications and required Gradle dependencies. ```Unity - Configure OAuth2 Authorize support: - Add an activity with a custom URL scheme to your application manifest. - An example build processor is provided at 'Assets/Scripts/Editor/AndroidPostBuildProcessor.cs'. - Add Gradle dependency: - Ensure 'androidx.browser' is added as a Gradle dependency. - Use Google External Dependency Manager or set up manually. ``` -------------------------------- ### Discord Social SDK Authentication Methods Overview Source: https://discord.com/developers/docs/social-sdk/index.html/authentication The Discord Social SDK supports two primary authentication methods: a standard OAuth2 flow for users with existing Discord accounts and a provisional account flow for users without Discord accounts, allowing authentication via external providers. This section provides an overview of these methods and references detailed guides for implementation. ```Conceptual Authentication Methods: 1. Standard OAuth2 flow for existing Discord accounts. 2. Provisional accounts for users authenticating via external providers. Related Guides: - Account Linking with Discord: https://discord.com/developers/docs/discord-social-sdk/development-guides/account-linking-with-discord - Using Provisional Accounts: https://discord.com/developers/docs/discord-social-sdk/development-guides/using-provisional-accounts ``` -------------------------------- ### Merge Discord Provisional Accounts (Console API) with Python Source: https://discord.com/developers/docs/social-sdk/index.html/authentication This Python example demonstrates how to merge provisional Discord accounts for console applications by exchanging a device code via the OAuth2 token endpoint. It includes parameters for `grant_type`, `device_code`, `external_auth_type`, and `external_auth_token`. The `requests` library is used for the server-to-server POST request. ```Python import requests API_ENDPOINT = 'https://discord.com/api/v10' CLIENT_ID = '332269999912132097' CLIENT_SECRET = '937it3ow87i4ery69876wqire' EXTERNAL_AUTH_TYPE = 'OIDC' def exchange_device_code_with_merge(device_code): data = { 'grant_type': 'urn:ietf:params:oauth:grant-type:device_code', 'device_code': device_code, 'external_auth_type': EXTERNAL_AUTH_TYPE, 'external_auth_token': external_auth_token } headers = { 'Content-Type': 'application/x-www-form-urlencoded' } r = requests.post('%s/oauth2/token' % API_ENDPOINT, data=data, headers=headers, auth=(CLIENT_ID, CLIENT_SECRET)) r.raise_for_status() return r.json() ``` -------------------------------- ### Merge Discord Provisional Accounts (Desktop/Mobile API) with Python Source: https://discord.com/developers/docs/social-sdk/index.html/authentication This Python example illustrates how to merge provisional Discord accounts for desktop and mobile applications by exchanging an authorization code via the OAuth2 token endpoint. It includes parameters for `grant_type`, `code`, `redirect_uri`, `external_auth_type`, and `external_auth_token`. The `requests` library is used for the server-to-server POST request. ```Python import requests API_ENDPOINT = 'https://discord.com/api/v10' CLIENT_ID = '332269999912132097' CLIENT_SECRET = '937it3ow87i4ery69876wqire' EXTERNAL_AUTH_TYPE = 'OIDC' def exchange_code_with_merge(code, redirect_uri, external_auth_token): data = { 'grant_type': 'authorization_code', 'code': code, 'redirect_uri': redirect_uri, 'external_auth_type': EXTERNAL_AUTH_TYPE, 'external_auth_token': external_auth_token } headers = { 'Content-Type': 'application/x-www-form-urlencoded' } r = requests.post('%s/oauth2/token' % API_ENDPOINT, data=data, headers=headers, auth=(CLIENT_ID, CLIENT_SECRET)) r.raise_for_status() return r.json() ``` -------------------------------- ### C++ ActivityTimestamps Get Start Time Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1ActivityTimestamps Retrieves the start time of the activity. This method returns the timestamp representing when the activity began, in milliseconds since the Unix epoch. The Discord client uses this value to display a count-up timer. ```APIDOC Method: uint64_t discordpp::ActivityTimestamps::Start() const Description: The time the activity started, in milliseconds since Unix epoch. The SDK will try to convert seconds to milliseconds if a small-ish value is passed in. If specified, the Discord client will render a count up timer showing how long the user has been playing this activity. Parameters: None Return: uint64_t - The start time in milliseconds since Unix epoch. ``` -------------------------------- ### Enable Launch Commands from Steam Runtime (Linux) Source: https://discord.com/developers/docs/social-sdk/index.html/release_notes Client::RegisterLaunchCommand and Client::RegisterLaunchSteamApplication now function correctly from inside the Steam Runtime on Linux. This expands the compatibility and utility of these methods for games running within the Steam environment. ```APIDOC Methods: Client::RegisterLaunchCommand, Client::RegisterLaunchSteamApplication Platform: Linux (Steam Runtime) Feature: Now work correctly within Steam Runtime. ``` -------------------------------- ### C++ Discord Call: OnSpeakingStatusChanged Typedef Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1Call Defines a callback function type for handling changes in a user's speaking status within a voice call. This typedef is used with Call::SetSpeakingStatusChangedCallback to detect when users start or stop speaking. ```C++ using discordpp::Call::OnSpeakingStatusChanged = std::function; ``` -------------------------------- ### C++: OnSpeakingStatusChanged Callback Type Definition Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1Call This type alias defines the signature for a callback function invoked whenever a user starts or stops speaking. It is used with Call::SetSpeakingStatusChangedCallback and provides the user's ID and a boolean indicating if they are currently speaking. ```C++ using OnSpeakingStatusChanged = std::function ``` -------------------------------- ### Configure C++ Standalone SDK Implementation Source: https://discord.com/developers/docs/social-sdk/index.html/installation This snippet shows how to define DISCORDPP_IMPLEMENTATION in one C++ file to include the necessary SDK implementation code. This is required before including discordpp.h to ensure the C++ SDK is properly linked and initialized. ```C++ #define DISCORDPP_IMPLEMENTATION ``` -------------------------------- ### C++ discordpp::AudioDevice Class API Documentation Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1AudioDevice This snippet provides the full API documentation for the `discordpp::AudioDevice` class, including its detailed description, public member functions (constructors, operators, and methods), and static public attributes. It outlines parameters, return types, and purpose for each element. ```APIDOC Class: discordpp::AudioDevice Description: Represents a single input or output audio device available to the user. Discord will initialize the audio engine with the system default input and output devices. You can change the device through the Client by passing the id of the desired audio device. Public Member Functions: - AudioDevice(AudioDevice &&other) noexcept Description: Move constructor for AudioDevice. Parameters: - other: AudioDevice && (The other AudioDevice object to move from.) Returns: void - AudioDevice & operator=(AudioDevice &&other) noexcept Description: Move assignment operator for AudioDevice. Parameters: - other: AudioDevice && (The other AudioDevice object to move from.) Returns: AudioDevice & - operator bool() const Description: Returns true if the instance contains a valid object. Parameters: None Returns: bool - AudioDevice(const AudioDevice &arg0) Description: Copy constructor for AudioDevice. Parameters: - arg0: const AudioDevice & (The AudioDevice object to copy from.) Returns: void - AudioDevice & operator=(const AudioDevice &arg0) Description: Copy assignment operator for AudioDevice. Parameters: - arg0: const AudioDevice & (The AudioDevice object to copy from.) Returns: AudioDevice & - bool Equals(discordpp::AudioDevice rhs) Description: Compares the ID of two AudioDevice objects for equality. Parameters: - rhs: discordpp::AudioDevice (The other AudioDevice object to compare with.) Returns: bool - std::string Id() const Description: The ID of the audio device. Parameters: None Returns: std::string - void SetId(std::string Id) Description: Setter for AudioDevice::Id. Parameters: - Id: std::string (The ID to set for the audio device.) Returns: void - std::string Name() const Description: The display name of the audio device. Parameters: None Returns: std::string - void SetName(std::string Name) Description: Setter for AudioDevice::Name. Parameters: - Name: std::string (The display name to set for the audio device.) Returns: void - bool IsDefault() const Description: Whether the audio device is the system default device. Parameters: None Returns: bool - void SetIsDefault(bool IsDefault) Description: Setter for AudioDevice::IsDefault. Parameters: - IsDefault: bool (The default status to set for the audio device.) Returns: void Static Public Attributes: - static const AudioDevice nullobj Description: Uninitialized instance of AudioDevice. Type: static const AudioDevice ``` -------------------------------- ### C++ ClientResult Get Rate Limit Retry Duration Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1ClientResult This method returns the number of seconds to wait before retrying an API request when the user is rate-limited (HTTP status 429). This field is set specifically in rate-limiting scenarios to guide retry logic. ```C++ float discordpp::ClientResult::RetryAfter() const ``` -------------------------------- ### APIDOC: discordpp::RunCallbacks() Function Source: https://discord.com/developers/docs/social-sdk/index.html/md_pages_2mobile This API documentation describes the 'RunCallbacks' function within the 'discordpp' namespace. This function is crucial for the Discord Social SDK to process its internal callbacks and must be regularly invoked within the application's main game loop. ```APIDOC Namespace: discordpp Function: RunCallbacks() Description: Ensures that Discord Social SDK callbacks are processed. Parameters: None. Return Type: Not specified in source. Usage: Must be called periodically (e.g., every frame) in the main game loop to allow the SDK to process events and maintain connectivity. ``` -------------------------------- ### Discordpp Client API Reference Source: https://discord.com/developers/docs/social-sdk/index.html/functions_b Detailed API documentation for the `discordpp::Client` class, including its methods and their usage. This section outlines the functionality, parameters, and return values for interacting with the Discord API through the client object. ```APIDOC { "class": "discordpp::Client", "description": "Represents the Discord++ client, providing methods to interact with the Discord API and manage social interactions.", "methods": [ { "name": "BlockUser", "signature": "BlockUser()", "description": "Blocks a specified user. This method is part of the client's social interaction capabilities, allowing applications to manage user relationships.", "parameters": [], "returns": { "type": "void", "description": "No explicit return value. The operation is typically asynchronous and may involve internal state changes or event emissions upon completion." } } ] } ``` -------------------------------- ### Discord Social SDK: Voice API Enhancements and Fixes Source: https://discord.com/developers/docs/social-sdk/index.html/release_notes The 1.0 release includes several updates to the Voice API. `Call::GetVADThreshold` has been added for voice activity detection. Fixes address issues with `Client::SetSelfDeafAll` and a crash in lobby voice after network dropout on Xbox. Documentation for `Client::StartCall` has been improved to clarify its behavior when attempting to start a call in an already active lobby. ```APIDOC // Added function: // Call::GetVADThreshold() // Returns: float - The Voice Activity Detection (VAD) threshold. // Behavior clarification for existing API: // Client::StartCall(lobbyId) // Returns: Call* or null // Note: Will return null if attempting to start a call in a lobby while already in a call for that same lobby. ``` -------------------------------- ### C++: Set Callback for Speaking Status Changes Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1Call This function registers a callback that is invoked whenever a user starts or stops speaking in a voice call. The callback receives the user's ID and a boolean indicating whether they are currently speaking, allowing for real-time UI updates. ```C++ void SetSpeakingStatusChangedCallback (discordpp::Call::OnSpeakingStatusChanged cb) ``` -------------------------------- ### Delay Voice Engine Initialization Source: https://discord.com/developers/docs/social-sdk/index.html/release_notes Initialization of the voice engine is now delayed until it is needed. This optimization improves application startup performance and resource utilization by only loading voice components when they are actively required. ```APIDOC Feature: Voice Engine Optimization: Initialization delayed until needed. ``` -------------------------------- ### Documenting discordpp::ActivityInvite C++ Class API Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1ActivityInvite This snippet provides the structured API documentation for the `discordpp::ActivityInvite` C++ class. It outlines the class's static attributes, constructors, and member functions, including their return types, parameters, and descriptions. This documentation is crucial for developers integrating Discord game invites into their applications. ```APIDOC class discordpp::ActivityInvite { public: // Static Public Attributes static const ActivityInvite nullobj; // Uninitialized instance of ActivityInvite. // Constructors ActivityInvite(ActivityInvite&& other) noexcept; // Move constructor. ActivityInvite(const ActivityInvite& rhs); // Copy constructor. // Member Functions uint64_t ApplicationId() const; // The target application of the invite. uint64_t ChannelId() const; // The id of the Discord channel in which the invite was sent. bool IsValid() const; // Whether or not this invite is currently joinable. An invite becomes invalid if it was sent more than 6 hours ago or if the sender is no longer playing the game the invite is for. void SetIsValid(bool IsValid); // Setter for ActivityInvite::IsValid. uint64_t MessageId() const; // The id of the Discord message that contains the invite. operator bool() const inline; // Returns true if the instance contains a valid object. ActivityInvite& operator=(ActivityInvite&& other) noexcept; // Move assignment operator. ActivityInvite& operator=(const ActivityInvite& rhs); // Copy assignment operator. std::string PartyId() const; // The id of the party the invite was sent for. uint64_t SenderId() const; // The user id of the user who sent the invite. }; ``` -------------------------------- ### Streamline Unity and Unreal Plugin Packaging Source: https://discord.com/developers/docs/social-sdk/index.html/release_notes Unity and Unreal plugin artifacts now contain only additional files for console support, designed to be extracted on top of the base plugin. The Unity plugin is now packaged as a .zip for extraction into the project's Packages directory. This simplifies plugin management and integration. ```APIDOC Packaging: Unity and Unreal plugin artifacts contain console-specific files. Unity Plugin: Packaged as .zip for extraction into Packages directory. ``` -------------------------------- ### Discord Social SDK Lobby Invite Flow Overview Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1Activity This section outlines a typical conceptual flow for integrating Discord lobbies with rich presence for game invites. It describes the sequence of actions from creating a lobby and updating rich presence to accepting an invite and joining the corresponding lobby. ```APIDOC When a user starts playing the game, they create a lobby with a random secret string, using Client::CreateOrJoinLobby That user publishes their RichPresence with the join secret set to the lobby secret, along with party size information Another use can then see that RichPresence on Discord and join off of it Once accepted the new user receives the join secret and their client can call CreateOrJoinLobby(joinSecret) to join the lobby Finally the original user can notice that the lobby membership has changed and so they publish a new RichPresence update containing the updating party size information. ``` -------------------------------- ### C++ ActivityTimestamps Set Start Time Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1ActivityTimestamps Sets the start time for the activity. This method updates the `Start` timestamp within the `ActivityTimestamps` object, which represents the time the activity began. ```APIDOC Method: void discordpp::ActivityTimestamps::SetStart(uint64_t Start) Description: Setter for ActivityTimestamps::Start. Parameters: - Start (uint64_t): The time the activity started, in milliseconds since Unix epoch. Return: void ``` -------------------------------- ### Configure Discord SDK Logging and Status Callbacks (C++) Source: https://discord.com/developers/docs/social-sdk/index.html/getting_started This C++ snippet demonstrates how to attach logging and status change callbacks to the `discordpp::Client` instance. The log callback prints messages with severity, while the status callback monitors the SDK's connection state, indicating when it's ready for use or if an error occurs, allowing the application to react accordingly. ```C++ client->AddLogCallback([](auto message, auto severity) { printf("[%s] %s", discordpp::LoggingSeverityToString(severity).c_str(), message.c_str()); }, discordpp::LoggingSeverity::Info); client->SetStatusChangedCallback([client](auto status, auto error, auto details) { printf("Status has changed to %s\n", discordpp::Client::StatusToString(status).c_str()); if (status == discordpp::Client::Status::Ready) { printf("Client is ready, you can now call SDK functions. For example:\n"); printf("You have %d friends\n", static_cast(client->GetRelationships().size())); } else if (error != discordpp::Client::Error::None) { printf("Error connecting: %s %d\n", discordpp::Client::ErrorToString(error).c_str(), details); } }); ``` -------------------------------- ### discordpp Namespace Reference Source: https://discord.com/developers/docs/social-sdk/index.html/namespacediscordpp Documents the discordpp namespace, which contains the generated Discord SDK bindings. This namespace is the primary entry point for accessing the SDK's functionalities. ```APIDOC { "type": "Namespace", "name": "discordpp", "description": "The namespace for the generated Discord SDK bindings.", "sections": [ { "title": "Overview", "content": "This namespace serves as the container for all generated Discord SDK bindings, providing access to core functionalities for interacting with the Discord API." }, { "title": "Related Sections", "links": [ { "text": "Classes", "ref": "#nested-classes" }, { "text": "Enumerations", "ref": "#enum-members" }, { "text": "Functions", "ref": "#func-members" } ] } ] } ``` -------------------------------- ### APIDOC: Get Discord Lobby (GET /lobbies/) Source: https://discord.com/developers/docs/social-sdk/index.html/server_apis This API endpoint retrieves the Lobby object for a specified Discord lobby. It returns the lobby's details if it exists. This is useful for fetching current lobby information. ```APIDOC Method: GET Path: /lobbies/ ``` -------------------------------- ### APIDOC: discordpp::Client::Status::Ready Enum Member Source: https://discord.com/developers/docs/social-sdk/index.html/getting_started Documents the `Ready` member of the `discordpp::Client::Status` enum. This status indicates that the Discord SDK client has successfully initialized and is ready to process API calls. ```APIDOC Enum Member: discordpp::Client::Status::Ready Description: Ready. Definition: discordpp.h:2964 ``` -------------------------------- ### Include Console-Specific README in Archives Source: https://discord.com/developers/docs/social-sdk/index.html/release_notes Console archives now include a small README file containing console-specific documentation. This provides developers with immediate access to relevant information for console integration, improving the onboarding experience. ```APIDOC Packaging: Console archives now include a README with console-specific documentation. ``` -------------------------------- ### JSON: Discord Device Authorization Response Schema Source: https://discord.com/developers/docs/social-sdk/index.html/authentication This JSON snippet illustrates the expected response structure from the Discord device authorization endpoint. It provides crucial information such as `device_code` for subsequent token exchange, `user_code` and `verification_uri` for user interaction, and `expires_in` and `interval` for polling logic. Developers should use these values to guide the user through the authorization process and manage polling for token acquisition. ```JSON { "device_code": "", "user_code": "", "verification_uri": "https://discord.com/activate", "verification_uri_complete": "https://discord.com/activate?user_code=", "expires_in": 300, "interval": 5 } ``` -------------------------------- ### C++: Get Type from discordpp::ChannelHandle Source: https://discord.com/developers/docs/social-sdk/index.html/functions_func_t Retrieves the type of a channel handle. This method is part of the `discordpp::ChannelHandle` class and indicates the nature of the channel. ```C++ discordpp::ChannelType discordpp::ChannelHandle::Type() ``` -------------------------------- ### Configure Unity Plugin NativeMethods Class Source: https://discord.com/developers/docs/social-sdk/index.html/installation This section details specific configuration options available on the NativeMethods static class within the Unity plugin. These options allow control over callback threading and unhandled exception handling. ```APIDOC Class: NativeMethods (static) Properties: - Name: UseSynchronizationContext Type: boolean Default: true Description: When true, callbacks from the SDK are posted to the synchronization context and run on the Unity game thread. If false, callbacks run directly on their originating thread (typically an internal SDK client thread). Events: - Name: UnhandledException Type: event Description: Triggered if an unhandled exception is thrown by an SDK callback. By default, exceptions are logged to Unity's debug log via Debug.LogException. ``` -------------------------------- ### C++: Get Type from discordpp::AdditionalContent Source: https://discord.com/developers/docs/social-sdk/index.html/functions_func_t Retrieves the type of additional content. This method is part of the `discordpp::AdditionalContent` class and categorizes the supplementary material. ```C++ discordpp::ContentType discordpp::AdditionalContent::Type() ``` -------------------------------- ### discordpp::Client Class API Reference Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1Client-members Detailed API documentation for the discordpp::Client class, including methods for interacting with Discord's social features and managing client-side settings. This section outlines function signatures, parameters, and type definitions. ```APIDOC Method: SendGameFriendRequest Class: discordpp::Client Parameters: username: std::string const & cb: discordpp::Client::SendFriendRequestCallback Method: SendGameFriendRequestById Class: discordpp::Client Parameters: userId: uint64_t cb: discordpp::Client::UpdateRelationshipCallback Method: SendLobbyMessage Class: discordpp::Client Parameters: lobbyId: uint64_t content: std::string const & cb: discordpp::Client::SendUserMessageCallback Method: SendLobbyMessageWithMetadata Class: discordpp::Client Parameters: lobbyId: uint64_t content: std::string const & metadata: std::unordered_map< std::string, std::string > const & cb: discordpp::Client::SendUserMessageCallback Method: SendUserMessage Class: discordpp::Client Parameters: recipientId: uint64_t content: std::string const & cb: discordpp::Client::SendUserMessageCallback Type Definition: SendUserMessageCallback Class: discordpp::Client Type: typedef Method: SendUserMessageWithMetadata Class: discordpp::Client Parameters: recipientId: uint64_t content: std::string const & metadata: std::unordered_map< std::string, std::string > const & cb: discordpp::Client::SendUserMessageCallback Method: SetActivityInviteCreatedCallback Class: discordpp::Client Parameters: cb: discordpp::Client::ActivityInviteCallback Method: SetActivityInviteUpdatedCallback Class: discordpp::Client Parameters: cb: discordpp::Client::ActivityInviteCallback Method: SetActivityJoinCallback Class: discordpp::Client Parameters: cb: discordpp::Client::ActivityJoinCallback Method: SetApplicationId Class: discordpp::Client Parameters: applicationId: uint64_t Method: SetAuthorizeDeviceScreenClosedCallback Class: discordpp::Client Parameters: cb: discordpp::Client::AuthorizeDeviceScreenClosedCallback Method: SetAutomaticGainControl Class: discordpp::Client Parameters: on: bool Method: SetDeviceChangeCallback Class: discordpp::Client Parameters: callback: discordpp::Client::DeviceChangeCallback Method: SetEchoCancellation Class: discordpp::Client Parameters: on: bool Method: SetEngineManagedAudioSession Class: discordpp::Client Parameters: isEngineManaged: bool Method: SetGameWindowPid Class: discordpp::Client Parameters: pid: int32_t Method: SetHttpRequestTimeout Class: discordpp::Client Parameters: httpTimeoutInMilliseconds: int32_t Method: SetInputDevice Class: discordpp::Client Parameters: deviceId: std::string cb: discordpp::Client::SetInputDeviceCallback Type Definition: SetInputDeviceCallback Class: discordpp::Client Type: typedef Method: SetInputVolume Class: discordpp::Client Parameters: inputVolume: float Method: SetLobbyCreatedCallback Class: discordpp::Client Parameters: cb: discordpp::Client::LobbyCreatedCallback Method: SetLobbyDeletedCallback Class: discordpp::Client Parameters: cb: discordpp::Client::LobbyDeletedCallback Method: SetLobbyMemberAddedCallback Class: discordpp::Client Parameters: cb: discordpp::Client::LobbyMemberAddedCallback ``` -------------------------------- ### C++: Get Type from discordpp::ActivityInvite Source: https://discord.com/developers/docs/social-sdk/index.html/functions_func_t Retrieves the type of an activity invite. This method is part of the `discordpp::ActivityInvite` class and specifies the kind of invite. ```C++ discordpp::ActivityInviteType discordpp::ActivityInvite::Type() ``` -------------------------------- ### Configure Discord Application for Provisional Accounts Source: https://discord.com/developers/docs/social-sdk/index.html/authentication This section outlines the required backend configuration for Discord applications to support provisional accounts, detailing required information for different identity providers (OIDC, Steam, EOS). This configuration is currently handled by contacting Discord directly. ```APIDOC // Required information for Discord Application Provisional Account Setup Discord Application ID: string External Provider Type: string (OIDC, Steam, EOS) // For Steam: Steam App ID: string // For EOS: EOS Client ID: string // For OIDC: Issuer: URL - Must have OIDC configuration available at /.well-known/openid-configuration - Configuration document must define: issuer, authorization_endpoint, token_endpoint, jwks_uri, id_token_signing_alg_values_supported - Supported id_token_signing_alg_values_supported: RS256, RS384, RS512, ES256, ES384, ES512, PS256, PS384, PS512 (must be signed) Audience: string (client identifier on the identity provider, used to validate 'aud' field in JWT) ``` -------------------------------- ### General Discord Server APIs and Authentication Source: https://discord.com/developers/docs/social-sdk/index.html/server_apis This section provides an overview of Discord's server-to-server APIs, detailing how they can be invoked and authenticated. It emphasizes the necessity of using a 'bot token' prefixed with 'Bot' for successful authentication and directs to the developer portal for comprehensive reference documentation. ```APIDOC Although the SDK does not require you to have a backend, for those who do, there are a number of APIs that can be invoked server to server. How these calls are made and structured and authenticated is documented on our developer portal here: https://discord.com/developers/docs/reference You'll need to use a "bot token" to authenticate these calls which can be found in the setting of the application you created above. And be sure the token is prefixed with `Bot` or it won't work! Discord publishes an Open API Spec at https://github.com/discord/discord-api-spec, and this can be used to generate a client in your preferred backend language to make it easier to call the various APIs. A good tool for that is https://openapi-generator.tech/ ``` -------------------------------- ### C++: Get Type from discordpp::Activity Source: https://discord.com/developers/docs/social-sdk/index.html/functions_func_t Retrieves the type of an activity. This method is part of the `discordpp::Activity` class and indicates the nature or category of the activity. ```C++ discordpp::ActivityType discordpp::Activity::Type() ``` -------------------------------- ### Get Lobby ID from Discord LinkedLobby Source: https://discord.com/developers/docs/social-sdk/index.html/functions_func_l Retrieves the unique identifier of a linked lobby. This function is part of the discordpp::LinkedLobby class and returns the ID of the associated lobby. ```C++ LobbyId LobbyId() ``` ```APIDOC { "class": "discordpp::LinkedLobby", "method": "LobbyId", "parameters": [], "returns": { "type": "LobbyId", "description": "The ID of the linked lobby." } } ``` -------------------------------- ### Discord++ Social SDK API Methods (A-Z) Source: https://discord.com/developers/docs/social-sdk/index.html/functions_func This snippet provides a structured API reference for various classes within the Discord++ Social SDK. It lists methods and constructors, indicating their parent class and basic signature. Parameters and return types are inferred or omitted if not explicitly provided in the source documentation. ```APIDOC ``` ```text ``` -------------------------------- ### C++: Update Token and Connect Discord SDK Source: https://discord.com/developers/docs/social-sdk/index.html/getting_started This snippet demonstrates how to update an existing authorization token and connect the Discord SDK. It shows passing the token to `UpdateToken` and then initiating the connection with `Connect()`. The SDK connects asynchronously, requiring a wait for `discordpp::Client::Status::Ready` before most functions are available. ```C++ client->UpdateToken(discordpp::AuthorizationTokenType::Bearer, accessToken, [client](auto result) { client->Connect(); }); ``` -------------------------------- ### C++ Discord Activity: Get Custom Buttons Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1Activity Returns the custom buttons for the rich presence. This method allows access to the interactive buttons configured for the activity. ```C++ std::vector discordpp::Activity::GetButtons() const ``` -------------------------------- ### C++: Retrieve Timestamps from discordpp::Activity Source: https://discord.com/developers/docs/social-sdk/index.html/functions_func_t Retrieves timestamp information associated with an activity. This method belongs to the `discordpp::Activity` class and provides details about when an activity started or ended. ```C++ discordpp::Timestamps discordpp::Activity::Timestamps() ``` -------------------------------- ### discordpp::Client Class Member Reference Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1Client-members This snippet provides a detailed API reference for the `discordpp::Client` class. It lists all available methods, constructors, and typedefs, along with their signatures, parameters, return types, and brief descriptions. Use this reference to understand and interact with Discord's social features through the SDK. ```APIDOC {"class_name":"discordpp::Client","summary":"Complete list of members for the discordpp::Client class, including inherited members.","members":[{"name":"AbortAuthorize","type":"method","signature":"AbortAuthorize()","return_type":"void","description":"Aborts an ongoing authorization process. This method can be called to cancel a pending authorization request, releasing any associated resources."}, {"name":"AbortGetTokenFromDevice","type":"method","signature":"AbortGetTokenFromDevice()","return_type":"void","description":"Aborts the process of getting a token from a device. ``` -------------------------------- ### Create or Get Discord LobbyHandle Source: https://discord.com/developers/docs/social-sdk/index.html/functions_func_l Constructs or retrieves a handle for a Discord lobby. This function is part of the discordpp::LobbyHandle class and provides a way to manage and interact with a specific lobby. ```C++ LobbyHandle LobbyHandle(LobbyId lobbyId) ``` ```APIDOC { "class": "discordpp::LobbyHandle", "method": "LobbyHandle", "parameters": [ { "name": "lobbyId", "type": "LobbyId", "description": "The ID of the lobby." } ], "returns": { "type": "LobbyHandle", "description": "A handle to the specified lobby." } } ``` -------------------------------- ### Configure Visual Studio for Discord SDK Debugging Source: https://discord.com/developers/docs/social-sdk/index.html/installation This snippet provides the URL for Discord SDK debugging symbols. Add this link to your Visual Studio debugger settings to enable proper symbol loading for debugging SDK-related issues. ```Configuration Symbol Server URL: https://storage.googleapis.com/discord-public-symbols Visual Studio Path: Tools > Options > Debugging > Symbols ``` -------------------------------- ### Get Lobby from Discord MessageHandle Source: https://discord.com/developers/docs/social-sdk/index.html/functions_func_l Retrieves the lobby associated with a message handle. This function is part of the discordpp::MessageHandle class and allows accessing lobby information from a message context. ```C++ Lobby Lobby() ``` ```APIDOC { "class": "discordpp::MessageHandle", "method": "Lobby", "parameters": [], "returns": { "type": "Lobby", "description": "The lobby object associated with the message." } } ``` -------------------------------- ### Discord++ Social SDK API Method Definitions Source: https://discord.com/developers/docs/social-sdk/index.html/functions_s This section lists the core methods and properties available within the Discord++ Social SDK, organized by their respective classes. Each entry specifies the method name and its return type, providing a clear overview of the API's functional surface. ```APIDOC Class: discordpp::Activity Method: SetState() Returns: discordpp::Activity Method: SetSupportedPlatforms() Returns: discordpp::Activity Method: SetTimestamps() Returns: discordpp::Activity Method: SetType() Returns: discordpp::Activity Method: State() Returns: discordpp::Activity Method: SupportedPlatforms() Returns: discordpp::Activity Class: discordpp::ActivityAssets Method: SmallImage() Returns: discordpp::ActivityAssets Method: SmallText() Returns: discordpp::ActivityAssets Class: discordpp::ActivityButton Method: SetUrl() Returns: discordpp::ActivityButton Class: discordpp::ActivityInvite Method: SetType() Returns: discordpp::ActivityInvite Class: discordpp::ActivityTimestamps Method: Start() Returns: discordpp::ActivityTimestamps Class: discordpp::AdditionalContent Method: SetTitle() Returns: discordpp::AdditionalContent Method: SetType() Returns: discordpp::AdditionalContent Class: discordpp::AuthorizationArgs Method: SetState() Returns: discordpp::AuthorizationArgs Method: State() Returns: discordpp::AuthorizationArgs Class: discordpp::AuthorizationCodeVerifier Method: SetVerifier() Returns: discordpp::AuthorizationCodeVerifier Class: discordpp::Call Method: SetStatusChangedCallback() Returns: discordpp::Call Method: SetVADThreshold() Returns: discordpp::Call Method: Status Returns: discordpp::Call Method: StatusToString() Returns: discordpp::Call Class: discordpp::Client Method: SetStatusChangedCallback() Returns: discordpp::Client Method: SetThreadPriority() Returns: discordpp::Client Method: SetTokenExpirationCallback() Returns: discordpp::Client Method: SetUserUpdatedCallback() Returns: discordpp::Client Method: SetVoiceLogDir() Returns: discordpp::Client Method: SetVoiceParticipantChangedCallback() Returns: discordpp::Client Method: ShowAudioRoutePicker() Returns: discordpp::Client Method: StartCall() Returns: discordpp::Client Method: StartCallWithAudioCallbacks() Returns: discordpp::Client Method: Status Returns: discordpp::Client Method: StatusToString() Returns: discordpp::Client Class: discordpp::ClientResult Method: SetStatus() Returns: discordpp::ClientResult Method: SetSuccessful() Returns: discordpp::ClientResult Method: SetType() Returns: discordpp::ClientResult Method: Status Returns: discordpp::ClientResult Method: Successful() Returns: discordpp::ClientResult Class: discordpp::UserHandle Method: Status Returns: discordpp::UserHandle Class: discordpp::VADThresholdSettings Method: SetVadThreshold() Returns: discordpp::VADThresholdSettings ``` -------------------------------- ### Get Label from Discord ActivityButton Source: https://discord.com/developers/docs/social-sdk/index.html/functions_func_l Retrieves the label associated with a Discord ActivityButton. This function is part of the discordpp::ActivityButton class and returns a string representing the button's text. ```C++ std::string Label() ``` ```APIDOC { "class": "discordpp::ActivityButton", "method": "Label", "parameters": [], "returns": { "type": "std::string", "description": "The label of the activity button." } } ``` -------------------------------- ### C++ Discord Activity: Get Activity Name Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1Activity Retrieves the name of the game or application that the activity is associated with. This field cannot be set by the SDK and will always be the name of the current game. ```C++ std::string discordpp::Activity::Name() const ``` -------------------------------- ### Discord SDK C++ Class Reference Source: https://discord.com/developers/docs/social-sdk/index.html/namespacediscordpp Lists the core C++ classes available in the Discord SDK bindings, detailing their purpose and functionality for various Discord features like activities, invites, calls, and client management. ```APIDOC Classes: - class Activity Description: An Activity represents one "thing" a user is doing on Discord and is part of their rich presence. - class ActivityAssets Description: Struct which controls what your rich presence looks like in the Discord client. If you don't specify any values, the icon and name of your application will be used as defaults. - class ActivityButton Description: No detailed description available in this snippet. - class ActivityInvite Description: When one user invites another to join their game on Discord, it will send a message to that user. The SDK will parse those messages for you automatically, and this struct contains all of the relevant invite information which is needed to later accept that invite. - class ActivityParty Description: No detailed description available in this snippet. - class ActivitySecrets Description: No detailed description available in this snippet. - class ActivityTimestamps Description: No detailed description available in this snippet. - class AdditionalContent Description: Contains information about non-text content in a message that likely cannot be rendered in game such as images, videos, embeds, polls, and more. - class AudioDevice Description: Represents a single input or output audio device available to the user. - class AuthorizationArgs Description: Arguments to the Client::Authorize function. - class AuthorizationCodeChallenge Description: Struct that encapsulates the challenge part of the code verification flow. - class AuthorizationCodeVerifier Description: Struct that encapsulates both parts of the code verification flow. - class Call Description: Class that manages an active voice session in a Lobby. - class CallInfoHandle Description: Convenience class that represents the state of a single Discord call in a lobby. - class ChannelHandle Description: All messages sent on Discord are done so in a Channel. MessageHandle::ChannelId will contain the ID of the channel a message was sent in, and Client::GetChannelHandle will return an instance of this class. - class Client Description: The Client class is the main entry point for the Discord SDK. All functionality is exposed through this class. - class ClientResult Description: Struct that stores information about the result of an SDK function call. - class DeviceAuthorizationArgs Description: Arguments to the Client::GetTokenFromDevice function. - class GuildChannel Description: No detailed description available in this snippet. ``` -------------------------------- ### C++: Implement Discord Party Join Requests Source: https://discord.com/developers/docs/social-sdk/index.html/classdiscordpp_1_1Activity This snippet demonstrates the full flow for users requesting to join parties. It covers creating a lobby, updating rich presence with a join secret, sending and receiving join requests, and accepting invites to join a lobby. This functionality requires the Discord Social SDK. ```C++ // User A // 1. Create a lobby with secret std::string lobbySecret = "foo"; client->CreateOrJoinLobby(lobbySecret, [=](discordpp::ClientResult result, uint64_t lobbyId) { // 2. Update rich presence with join secret discordpp::Activity activity{}; // set name, state, party size ... discordpp::ActivitySecrets secrets{}; secrets.SetJoin(lobbySecret); activity.SetSecrets(secrets); client->UpdateRichPresence(std::move(activity), [](discordpp::ClientResult result) {}); }); // User B // 3. Request to join User A's party client->SendActivityJoinRequest(USER_A_ID, [](auto result) {}); // User A // Monitor for new invites: client->SetActivityInviteCreatedCallback([client](auto invite) { // 5. The game can now show that User A has received a request to join their party // If User A is ok with that, they can reply back: // Note: invite.type will be ActivityActionTypes::JoinRequest in this example client->SendActivityJoinRequestReply(invite, [](auto result) {}); }); // User B // 6. Same as before, user B can monitor for invites client->SetActivityInviteCreatedCallback([client](auto invite) { // 7. When an invite is received, ask the user if they want to accept it. // If they choose to do so then go ahead and invoke AcceptActivityInvite client->AcceptActivityInvite(invite, [client](discordpp::ClientResult result, std::string secret) { if (result.Successful()) { // 5. Join the lobby using the joinSecret client->CreateOrJoinLobby(secret, [](auto result, uint64_t lobbyId) { // Successfully joined lobby! }); } }); }); ``` -------------------------------- ### C++: Get Type from discordpp::ClientResult Source: https://discord.com/developers/docs/social-sdk/index.html/functions_func_t Retrieves the type of a client operation result. This method is part of the `discordpp::ClientResult` class and provides an indication of the result's category or status. ```C++ discordpp::ClientResultType discordpp::ClientResult::Type() ```