Discord Social SDK
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
discordpp::Client Class Reference

Detailed Description

The Client class is the main entry point for the Discord SDK. All functionality is exposed through this class.

See Getting Started for more information on how to use the Client class.

Public Member Functions

 Client (Client &&other) noexcept
 Move constructor for Client.
 
Clientoperator= (Client &&other) noexcept
 Move assignment operator for Client.
 
 operator bool () const
 Returns true if the instance contains a valid object.
 
 Client (const Client &)=delete
 
Clientoperator= (const Client &)=delete
 
 Client ()
 Creates a new instance of the Client.
 
 Client (std::string apiBase, std::string webBase)
 Creates a new instance of the Client but allows customizing the Discord URL to use.
 
uint64_t GetApplicationId ()
 This function is used to get the application ID for the client. This is used to identify the application to the Discord client. This is used for things like authentication, rich presence, and activity invites when not connected with Client::Connect. When calling Client::Connect, the application ID is set automatically.
 
Audio
void EndCall (uint64_t channelId, discordpp::Client::EndCallCallback callback)
 Ends any active call, if any. Any references you have to Call objects are invalid after they are ended, and can be immediately freed.
 
void EndCalls (discordpp::Client::EndCallsCallback callback)
 Ends any active call, if any. Any references you have to Call objects are invalid after they are ended, and can be immediately freed.
 
discordpp::Call GetCall (uint64_t channelId)
 Returns a reference to the currently active call, if any.
 
std::vector< discordpp::CallGetCalls ()
 Returns a reference to all currently active calls, if any.
 
void GetCurrentInputDevice (discordpp::Client::GetCurrentInputDeviceCallback cb)
 Asynchronously fetches the current audio input device in use by the client.
 
void GetCurrentOutputDevice (discordpp::Client::GetCurrentOutputDeviceCallback cb)
 Asynchronously fetches the current audio output device in use by the client.
 
void GetInputDevices (discordpp::Client::GetInputDevicesCallback cb)
 Asynchronously fetches the list of audio input devices available to the user.
 
float GetInputVolume ()
 Returns the input volume for the current user's microphone.
 
void GetOutputDevices (discordpp::Client::GetOutputDevicesCallback cb)
 Asynchronously fetches the list of audio output devices available to the user.
 
float GetOutputVolume ()
 Returns the output volume for the current user.
 
bool GetSelfDeafAll () const
 Returns whether the current user is deafened in all calls.
 
bool GetSelfMuteAll () const
 Returns whether the current user's microphone is muted in all calls.
 
void SetAutomaticGainControl (bool on)
 When enabled, automatically adjusts the microphone volume to keep it clear and consistent.
 
void SetDeviceChangeCallback (discordpp::Client::DeviceChangeCallback callback)
 Sets a callback function to be invoked when Discord detects a change in the available audio devices.
 
void SetEchoCancellation (bool on)
 Enables or disables the basic echo cancellation provided by the WebRTC library.
 
void SetInputDevice (std::string deviceId, discordpp::Client::SetInputDeviceCallback cb)
 Asynchronously changes the audio input device in use by the client to the specified device. You can find the list of device IDs that can be passed in with the Client::GetInputDevices function.
 
void SetInputVolume (float inputVolume)
 Sets the microphone volume for the current user.
 
void SetNoAudioInputCallback (discordpp::Client::NoAudioInputCallback callback)
 Callback function invoked when the above threshold is set and there is a change in whether audio is being detected.
 
void SetNoAudioInputThreshold (float dBFSThreshold)
 Threshold that can be set to indicate when no audio is being received by the user's mic.
 
void SetNoiseSuppression (bool on)
 Enables basic background noise suppression.
 
void SetOpusHardwareCoding (bool encode, bool decode)
 Enables or disables hardware encoding and decoding for audio, if it is available.
 
void SetOutputDevice (std::string deviceId, discordpp::Client::SetOutputDeviceCallback cb)
 Asynchronously changes the audio output device in use by the client to the specified device. You can find the list of device IDs that can be passed in with the Client::GetOutputDevices function.
 
void SetOutputVolume (float outputVolume)
 Sets the speaker volume for the current user.
 
void SetSelfDeafAll (bool deaf)
 Mutes all audio from the currently active call for the current user in all calls. They will not be able to hear any other participants, and no other participants will be able to hear the current user either. Note: This overrides the per-call setting.
 
void SetSelfMuteAll (bool mute)
 Mutes the current user's microphone so that no other participant in their active calls can hear them in all calls. Note: This overrides the per-call setting.
 
bool SetSpeakerMode (bool speakerMode)
 On mobile devices, enable speakerphone mode.
 
void SetThreadPriority (discordpp::Client::Thread thread, int32_t priority)
 Allows setting the priority of various SDK threads.
 
void SetVoiceParticipantChangedCallback (discordpp::Client::VoiceParticipantChangedCallback cb)
 Callback invoked whenever a user in a lobby joins or leaves a voice call.
 
bool ShowAudioRoutePicker ()
 On iOS devices, show the system audio route picker.
 
discordpp::Call StartCall (uint64_t channelId)
 Starts or joins a call in the lobby specified by channelId (For a lobby, simply pass in the lobbyId).
 
discordpp::Call StartCallWithAudioCallbacks (uint64_t lobbyId, discordpp::Client::UserAudioReceivedCallback receivedCb, discordpp::Client::UserAudioCapturedCallback capturedCb)
 Starts or joins a call in the specified lobby.
 
Auth
void AbortAuthorize ()
 This will abort the authorize flow if it is in progress and tear down any associated state.
 
void AbortGetTokenFromDevice ()
 This function is used to abort/cleanup the device authorization flow.
 
void Authorize (discordpp::AuthorizationArgs args, discordpp::Client::AuthorizationCallback callback)
 Initiates an OAuth2 flow for a user to "sign in with Discord". This flow is intended for desktop and mobile devices. If you are implementing for the console, leverage the device auth flow instead (Client::GetTokenFromDevice or Client::OpenAuthorizeDeviceScreen).
 
void CloseAuthorizeDeviceScreen ()
 This function is used to hide the device authorization screen and is used for the case where the user is on a limited input device, such as a console or smart TV. This function should be used in conjunction with a backend server to handle the device authorization flow. For a public client, you can use Client::AbortGetTokenFromDevice instead.
 
discordpp::AuthorizationCodeVerifier CreateAuthorizationCodeVerifier ()
 Helper function that can create a code challenge and verifier for use in the Client::Authorize + Client::GetToken flow. This returns a struct with two items, a challenge value to pass into Client::Authorize and a verifier value to pass into GetToken.
 
void FetchCurrentUser (discordpp::AuthorizationTokenType tokenType, std::string const &token, discordpp::Client::FetchCurrentUserCallback callback)
 Fetches basic information about the user associated with the given auth token.
 
void GetProvisionalToken (uint64_t applicationId, discordpp::AuthenticationExternalAuthType externalAuthType, std::string const &externalAuthToken, discordpp::Client::TokenExchangeCallback callback)
 Provisional accounts are a way for users that have not signed up for Discord to still access SDK functionality. They are "placeholder" Discord accounts for the user that are owned and managed by your game. Provisional accounts exist so that your users can engage with Discord APIs and systems without the friction of creating their own Discord account. Provisional accounts and their data are unique per Discord application.
 
void GetToken (uint64_t applicationId, std::string const &code, std::string const &codeVerifier, std::string const &redirectUri, discordpp::Client::TokenExchangeCallback callback)
 Exchanges an authorization code that was returned from the Client::Authorize function for an access token which can be used to authenticate with the SDK.
 
void GetTokenFromDevice (discordpp::DeviceAuthorizationArgs args, discordpp::Client::TokenExchangeCallback callback)
 This function is a combination of Client::Authorize and Client::GetToken, but is used for the case where the user is on a limited input device, such as a console or smart TV.
 
void GetTokenFromDeviceProvisionalMerge (discordpp::DeviceAuthorizationArgs args, discordpp::AuthenticationExternalAuthType externalAuthType, std::string const &externalAuthToken, discordpp::Client::TokenExchangeCallback callback)
 This function is a combination of Client::Authorize and Client::GetTokenFromProvisionalMerge, but is used for the case where the user is on a limited input device, such as a console or smart TV.
 
void GetTokenFromProvisionalMerge (uint64_t applicationId, std::string const &code, std::string const &codeVerifier, std::string const &redirectUri, discordpp::AuthenticationExternalAuthType externalAuthType, std::string const &externalAuthToken, discordpp::Client::TokenExchangeCallback callback)
 This function should be used with the Client::Authorize function whenever a user with a provisional account wants to link to an existing Discord account or "upgrade" their provisional account into a "full" Discord account.
 
bool IsAuthenticated ()
 Returns true if the SDK has a non-empty OAuth2 token set, regardless of whether that token is valid or not.
 
void OpenAuthorizeDeviceScreen (uint64_t clientId, std::string const &userCode)
 This function is used to show the device authorization screen and is used for the case where the user is on a limited input device, such as a console or smart TV. This function should be used in conjunction with a backend server to handle the device authorization flow. For a public client, you can use Client::GetTokenFromDevice instead.
 
void ProvisionalUserMergeCompleted (bool success)
 Some functions don't work for provisional accounts, and require the user merge their account into a full Discord account before proceeding. This callback is invoked when an account merge must take place before proceeding. The developer is responsible for initiating the account merge, and then calling Client::ProvisionalUserMergeCompleted to signal to the SDK that the pending operation can continue with the new account.
 
void RefreshToken (uint64_t applicationId, std::string const &refreshToken, discordpp::Client::TokenExchangeCallback callback)
 Generates a new access token for the current user from a refresh token.
 
void SetAuthorizeDeviceScreenClosedCallback (discordpp::Client::AuthorizeDeviceScreenClosedCallback cb)
 Sets a callback function to be invoked when the device authorization screen is closed.
 
void SetGameWindowPid (int32_t pid)
 When users are linking their account with Discord, which involves an OAuth2 flow, the SDK can streamline it by using Discord's overlay so the interaction happens entirely in-game. If your game's main window is not the same process as the one running the integration you may need to set the window PID using this method. It defaults to the current pid.
 
void SetTokenExpirationCallback (discordpp::Client::TokenExpirationCallback callback)
 Get a notification when the current token is about to expire or expired.
 
void UpdateProvisionalAccountDisplayName (std::string const &name, discordpp::Client::UpdateProvisionalAccountDisplayNameCallback callback)
 Updates the display name of a provisional account to the specified name.
 
void UpdateToken (discordpp::AuthorizationTokenType tokenType, std::string token, discordpp::Client::UpdateTokenCallback callback)
 Asynchronously sets a new auth token for this client to use.
 
Chat
bool CanOpenMessageInDiscord (uint64_t messageId)
 Returns true if the given message is able to be viewed in a Discord client.
 
void DeleteUserMessage (uint64_t recipientId, uint64_t messageId, discordpp::Client::DeleteUserMessageCallback cb)
 Deletes the specified message sent by the current user to the specified recipient.
 
void EditUserMessage (uint64_t recipientId, uint64_t messageId, std::string const &content, discordpp::Client::EditUserMessageCallback cb)
 Edits the specified message sent by the current user to the specified recipient.
 
std::optional< discordpp::ChannelHandleGetChannelHandle (uint64_t channelId) const
 Returns a reference to the Discord channel object for the given ID.
 
std::optional< discordpp::MessageHandleGetMessageHandle (uint64_t messageId) const
 Returns a reference to the Discord message object for the given ID.
 
void OpenMessageInDiscord (uint64_t messageId, discordpp::Client::ProvisionalUserMergeRequiredCallback provisionalUserMergeRequiredCallback, discordpp::Client::OpenMessageInDiscordCallback callback)
 Opens the given message in the Discord client.
 
void SendLobbyMessage (uint64_t lobbyId, std::string const &content, discordpp::Client::SendUserMessageCallback cb)
 Sends a message in a lobby chat to all members of the lobby.
 
void SendLobbyMessageWithMetadata (uint64_t lobbyId, std::string const &content, std::unordered_map< std::string, std::string > const &metadata, discordpp::Client::SendUserMessageCallback cb)
 Variant of Client::SendLobbyMessage that also accepts metadata to be sent with the message.
 
void SendUserMessage (uint64_t recipientId, std::string const &content, discordpp::Client::SendUserMessageCallback cb)
 Sends a direct message to the specified user.
 
void SendUserMessageWithMetadata (uint64_t recipientId, std::string const &content, std::unordered_map< std::string, std::string > const &metadata, discordpp::Client::SendUserMessageCallback cb)
 Variant of Client::SendUserMessage that also accepts metadata to be sent with the message.
 
void SetMessageCreatedCallback (discordpp::Client::MessageCreatedCallback cb)
 Sets a callback to be invoked whenever a new message is received in either a lobby or a DM.
 
void SetMessageDeletedCallback (discordpp::Client::MessageDeletedCallback cb)
 Sets a callback to be invoked whenever a message is deleted.
 
void SetMessageUpdatedCallback (discordpp::Client::MessageUpdatedCallback cb)
 Sets a callback to be invoked whenever a message is edited.
 
void SetShowingChat (bool showingChat)
 Sets whether chat messages are currently being shown in the game.
 
Core
void AddLogCallback (discordpp::Client::LogCallback callback, discordpp::LoggingSeverity minSeverity)
 Adds a callback function to be invoked for each new log message generated by the SDK.
 
void AddVoiceLogCallback (discordpp::Client::LogCallback callback, discordpp::LoggingSeverity minSeverity)
 Adds a callback function to be invoked for each new log message generated by the voice subsystem of the SDK, including the underlying webrtc infrastructure.
 
void Connect ()
 Asynchronously connects the client to Discord.
 
void Disconnect ()
 Asynchronously disconnects the client.
 
discordpp::Client::Status GetStatus () const
 Returns the current status of the client, see the Status enum for an explanation of the possible values.
 
void OpenConnectedGamesSettingsInDiscord (discordpp::Client::OpenConnectedGamesSettingsInDiscordCallback callback)
 Opens the Connected Games settings in the Discord client, which is where users can manage their settings related to games using the Discord Social SDK.
 
void SetApplicationId (uint64_t applicationId)
 This function is used to set the application ID for the client. This is used to identify the application to the Discord client. This is used for things like authentication, rich presence, and activity invites when not connected with Client::Connect. When calling Client::Connect, the application ID is set automatically.
 
bool SetLogDir (std::string const &path, discordpp::LoggingSeverity minSeverity)
 Causes logs generated by the SDK to be written to disk in the specified directory.
 
void SetStatusChangedCallback (discordpp::Client::OnStatusChanged cb)
 Sets a callback function to be invoked whenever the SDKs status changes.
 
void SetVoiceLogDir (std::string const &path, discordpp::LoggingSeverity minSeverity)
 Causes logs generated by the voice subsystem of the SDK to be written to disk in the specified directory.
 
Lobbies
void CreateOrJoinLobby (std::string const &secret, discordpp::Client::CreateOrJoinLobbyCallback callback)
 Joins the user to the specified lobby, creating one if it does not exist.
 
void CreateOrJoinLobbyWithMetadata (std::string const &secret, std::unordered_map< std::string, std::string > const &lobbyMetadata, std::unordered_map< std::string, std::string > const &memberMetadata, discordpp::Client::CreateOrJoinLobbyCallback callback)
 Variant of Client::CreateOrJoinLobby that also accepts developer-supplied metadata.
 
void GetGuildChannels (uint64_t guildId, discordpp::Client::GetGuildChannelsCallback cb)
 Fetches all of the channels that the current user can access in the given guild.
 
std::optional< discordpp::LobbyHandleGetLobbyHandle (uint64_t lobbyId) const
 Returns a reference to the Discord lobby object for the given ID.
 
std::vector< uint64_t > GetLobbyIds () const
 Returns a list of all the lobbies that the user is a member of and the SDK has loaded.
 
void GetUserGuilds (discordpp::Client::GetUserGuildsCallback cb)
 Fetches all of the guilds (also known as Discord servers) that the current user is a member of.
 
void LeaveLobby (uint64_t lobbyId, discordpp::Client::LeaveLobbyCallback callback)
 Removes the current user from the specified lobby.
 
void LinkChannelToLobby (uint64_t lobbyId, uint64_t channelId, discordpp::Client::LinkOrUnlinkChannelCallback callback)
 Links the specified channel on Discord to the specified in-game lobby.
 
void SetLobbyCreatedCallback (discordpp::Client::LobbyCreatedCallback cb)
 Sets a callback to be invoked when a lobby "becomes available" to the client.
 
void SetLobbyDeletedCallback (discordpp::Client::LobbyDeletedCallback cb)
 Sets a callback to be invoked when a lobby is no longer available.
 
void SetLobbyMemberAddedCallback (discordpp::Client::LobbyMemberAddedCallback cb)
 Sets a callback function to be invoked whenever a user is added to a lobby.
 
void SetLobbyMemberRemovedCallback (discordpp::Client::LobbyMemberRemovedCallback cb)
 Sets a callback function to be invoked whenever a member of a lobby is removed and can no longer connect to it.
 
void SetLobbyMemberUpdatedCallback (discordpp::Client::LobbyMemberUpdatedCallback cb)
 Sets a callback function to be invoked whenever a member of a lobby is changed.
 
void SetLobbyUpdatedCallback (discordpp::Client::LobbyUpdatedCallback cb)
 Sets a callback to be invoked when a lobby is edited, for example if the lobby's metadata is changed.
 
void UnlinkChannelFromLobby (uint64_t lobbyId, discordpp::Client::LinkOrUnlinkChannelCallback callback)
 Removes any existing channel link from the specified lobby.
 
Presence
void AcceptActivityInvite (discordpp::ActivityInvite invite, discordpp::Client::AcceptActivityInviteCallback cb)
 Accepts an activity invite that the current user has received.
 
void ClearRichPresence ()
 Clears the right presence for the current user.
 
bool RegisterLaunchCommand (uint64_t applicationId, std::string command)
 When a user accepts an activity invite for your game within the Discord client, Discord needs to know how to launch the game for that user. This function allows you to register a command that Discord will run to launch your game. You should invoke this when the SDK starts up so that if the user in the future tries to join from Discord the game will be able to be launched for them. Returns true if the command was successfully registered, false otherwise.
 
bool RegisterLaunchSteamApplication (uint64_t applicationId, uint32_t steamAppId)
 When a user accepts an activity invite for your game within the Discord client, Discord needs to know how to launch the game for that user. For steam games, this function allows you to indicate to Discord what the steam game ID is. You should invoke this when the SDK starts up so that if the user in the future tries to join from Discord the game will be able to be launched for them. Returns true if the command was successfully registered, false otherwise.
 
void SendActivityInvite (uint64_t userId, std::string const &content, discordpp::Client::SendActivityInviteCallback cb)
 Sends a Discord activity invite to the specified user.
 
void SendActivityJoinRequest (uint64_t userId, discordpp::Client::SendActivityInviteCallback cb)
 Requests to join the activity of the specified user.
 
void SendActivityJoinRequestReply (discordpp::ActivityInvite invite, discordpp::Client::SendActivityInviteCallback cb)
 When another user requests to join the current user's party, this function is called to to allow that user to join. Specifically this will send the original user an activity invite which they then need to accept again.
 
void SetActivityInviteCreatedCallback (discordpp::Client::ActivityInviteCallback cb)
 Sets a callback function that is invoked when the current user receives an activity invite from another user.
 
void SetActivityInviteUpdatedCallback (discordpp::Client::ActivityInviteCallback cb)
 Sets a callback function that is invoked when an existing activity invite changes. Currently, the only thing that changes on an activity invite is its validity. If the sender goes offline or exits the party the receiver was invited to, the invite is no longer joinable. It is possible for an invalid invite to go from invalid to valid if the sender rejoins the activity.
 
void SetActivityJoinCallback (discordpp::Client::ActivityJoinCallback cb)
 Sets a callback function that is invoked when the current user also has Discord running on their computer and they accept an activity invite in the Discord client.
 
void SetOnlineStatus (discordpp::StatusType status, discordpp::Client::UpdateStatusCallback callback)
 Sets whether a user is online/invisible/idle/dnd on Discord.
 
void UpdateRichPresence (discordpp::Activity activity, discordpp::Client::UpdateRichPresenceCallback cb)
 Updates the rich presence for the current user.
 
Relationships
void AcceptDiscordFriendRequest (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Accepts an incoming Discord friend request from the target user.
 
void AcceptGameFriendRequest (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Accepts an incoming game friend request from the target user.
 
void BlockUser (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Blocks the target user so that they cannot send the user friend or activity invites and cannot message them anymore.
 
void CancelDiscordFriendRequest (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Cancels an outgoing Discord friend request to the target user.
 
void CancelGameFriendRequest (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Cancels an outgoing game friend request to the target user.
 
discordpp::RelationshipHandle GetRelationshipHandle (uint64_t userId) const
 Returns the RelationshipHandle that corresponds to the relationship between the current user and the given user.
 
std::vector< discordpp::RelationshipHandleGetRelationships () const
 Returns a list of all of the relationships the current user has with others, including all Discord relationships and all Game relationships for the current game.
 
void RejectDiscordFriendRequest (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Declines an incoming Discord friend request from the target user.
 
void RejectGameFriendRequest (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Declines an incoming game friend request from the target user.
 
void RemoveDiscordAndGameFriend (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Removes any friendship between the current user and the target user. This function will remove BOTH any Discord friendship and any game friendship between the users.
 
void RemoveGameFriend (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Removes any game friendship between the current user and the target user.
 
std::vector< discordpp::UserHandleSearchFriendsByUsername (std::string searchStr) const
 Searches all of your friends by both username and display name, returning a list of all friends that match the search string.
 
void SendDiscordFriendRequest (std::string const &username, discordpp::Client::SendFriendRequestCallback cb)
 Sends a Discord friend request to the target user.
 
void SendDiscordFriendRequestById (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Sends a Discord friend request to the target user.
 
void SendGameFriendRequest (std::string const &username, discordpp::Client::SendFriendRequestCallback cb)
 Sends (or accepts) a game friend request to the target user.
 
void SendGameFriendRequestById (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Sends (or accepts) a game friend request to the target user.
 
void SetRelationshipCreatedCallback (discordpp::Client::RelationshipCreatedCallback cb)
 Sets a callback to be invoked whenever a relationship for this user is established or changes type.
 
void SetRelationshipDeletedCallback (discordpp::Client::RelationshipDeletedCallback cb)
 Sets a callback to be invoked whenever a relationship for this user is removed, such as when the user rejects a friend request or removes a friend.
 
void UnblockUser (uint64_t userId, discordpp::Client::UpdateRelationshipCallback cb)
 Unblocks the target user. Does not restore any old relationship between the users though.
 
Users
discordpp::UserHandle GetCurrentUser () const
 Returns the user associated with the current client.
 
void GetDiscordClientConnectedUser (uint64_t applicationId, discordpp::Client::GetDiscordClientConnectedUserCallback callback) const
 If the Discord app is running on the user's computer and the SDK establishes a connection to it, this function will return the user that is currently logged in to the Discord app.
 
std::optional< discordpp::UserHandleGetUser (uint64_t userId) const
 Returns the UserHandle associated with the given user ID.
 
void SetUserUpdatedCallback (discordpp::Client::UserUpdatedCallback cb)
 The UserUpdatedCallback is invoked whenever any user the current session knows about changes, not just if the current user changes. For example if one of your Discord friends changes their name or avatar the UserUpdatedCallback will be invoked. It is also invoked when users come online, go offline, or start playing your game.
 

Public Types

enum class  Error { None = 0 , ConnectionFailed = 1 , UnexpectedClose = 2 , ConnectionCanceled = 3 }
 Represents an error state for the socket connection that the Discord SDK maintains with the Discord backend. More...
 
enum class  Status {
  Disconnected = 0 , Connecting = 1 , Connected = 2 , Ready = 3 ,
  Reconnecting = 4 , Disconnecting = 5 , HttpWait = 6
}
 This enum refers to the status of the internal websocket the SDK uses to communicate with Discord There are ~2 phases for "launching" the client: More...
 
enum class  Thread { Client = 0 , Voice = 1 , Network = 2 }
 Represents the type of thread to control thread priority on. More...
 
using EndCallCallback = std::function<void()>
 Callback invoked when Client::EndCall completes.
 
using EndCallsCallback = std::function<void()>
 Callback invoked when Client::EndCalls completes.
 
using GetCurrentInputDeviceCallback = std::function<void(discordpp::AudioDevice device)>
 Callback function for Client::GetCurrentInputDevice.
 
using GetCurrentOutputDeviceCallback = std::function<void(discordpp::AudioDevice device)>
 Callback function for Client::GetCurrentOutputDevice.
 
using GetInputDevicesCallback
 Callback function for Client::GetInputDevices.
 
using GetOutputDevicesCallback
 Callback function for Client::GetOutputDevices.
 
using DeviceChangeCallback
 Callback function for Client::SetDeviceChangeCallback.
 
using SetInputDeviceCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for Client::SetInputDevice.
 
using NoAudioInputCallback = std::function<void(bool inputDetected)>
 Callback function for Client::SetNoAudioInputCallback.
 
using SetOutputDeviceCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for Client::SetOutputDevice.
 
using VoiceParticipantChangedCallback
 Callback function for Client::SetVoiceParticipantChangedCallback.
 
using UserAudioReceivedCallback
 Callback function for Client::StartCallWithAudioCallbacks.
 
using UserAudioCapturedCallback
 Callback function for Client::StartCallWithAudioCallbacks.
 
using AuthorizationCallback
 Callback invoked when the Authorize function completes.
 
using FetchCurrentUserCallback
 Callback function for Client::FetchCurrentUser.
 
using TokenExchangeCallback
 Callback function for the token exchange APIs such as Client::GetToken.
 
using AuthorizeDeviceScreenClosedCallback = std::function<void()>
 Callback function for Client::SetAuthorizeDeviceScreenClosedCallback.
 
using TokenExpirationCallback = std::function<void()>
 Callback function for Client::SetTokenExpirationCallback.
 
using UpdateProvisionalAccountDisplayNameCallback
 Callback function for Client::UpdateProvisionalAccountDisplayName.
 
using UpdateTokenCallback = std::function<void(discordpp::ClientResult result)>
 Callback invoked when Client::UpdateToken completes. Once this is done it is safe to call Client::Connect.
 
using DeleteUserMessageCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for Client::DeleteUserMessage.
 
using EditUserMessageCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for Client::EditUserMessage.
 
using ProvisionalUserMergeRequiredCallback = std::function<void()>
 Callback function for when Client::ProvisionalUserMergeCompleted completes.
 
using OpenMessageInDiscordCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for when Client::OpenMessageInDiscord completes.
 
using SendUserMessageCallback
 This is used for all kinds of 'send message' calls despite the name, to make sure engine bindings use the same delegate type declaration for all of them, which makes things nicer. SendMessageCallback was unavailable because it's a macro on Windows.
 
using MessageCreatedCallback = std::function<void(uint64_t messageId)>
 Callback function for Client::SetMessageCreatedCallback.
 
using MessageDeletedCallback = std::function<void(uint64_t messageId, uint64_t channelId)>
 Callback function for Client::SetMessageDeletedCallback.
 
using MessageUpdatedCallback = std::function<void(uint64_t messageId)>
 Callback function for Client::SetMessageUpdatedCallback.
 
using LogCallback
 Callback function invoked when a new log message is generated.
 
using OpenConnectedGamesSettingsInDiscordCallback
 Callback function for when Client::OpenConnectedGamesSettingsInDiscord completes.
 
using OnStatusChanged
 Callback function for Client::SetStatusChangedCallback.
 
using CreateOrJoinLobbyCallback
 Callback function for Client::CreateOrJoinLobby.
 
using GetGuildChannelsCallback
 Callback function for Client::GetGuildChannels.
 
using GetUserGuildsCallback
 Callback function for Client::GetUserGuilds.
 
using LeaveLobbyCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for Client::LeaveLobby.
 
using LinkOrUnlinkChannelCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for Client::LinkChannelToLobby.
 
using LobbyCreatedCallback = std::function<void(uint64_t lobbyId)>
 Callback function for Client::SetLobbyCreatedCallback.
 
using LobbyDeletedCallback = std::function<void(uint64_t lobbyId)>
 Callback function for Client::SetLobbyDeletedCallback.
 
using LobbyMemberAddedCallback = std::function<void(uint64_t lobbyId, uint64_t memberId)>
 Callback function for Client::SetLobbyMemberAddedCallback.
 
using LobbyMemberRemovedCallback = std::function<void(uint64_t lobbyId, uint64_t memberId)>
 Callback function for Client::SetLobbyMemberRemovedCallback.
 
using LobbyMemberUpdatedCallback = std::function<void(uint64_t lobbyId, uint64_t memberId)>
 Callback function for Client::SetLobbyMemberUpdatedCallback.
 
using LobbyUpdatedCallback = std::function<void(uint64_t lobbyId)>
 Callback function for Client::SetLobbyUpdatedCallback.
 
using AcceptActivityInviteCallback
 Callback function for Client::AcceptActivityInvite.
 
using SendActivityInviteCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for Client::SendActivityInvite, Client::SendActivityJoinRequest, and Client::SendActivityJoinRequestReply.
 
using ActivityInviteCallback = std::function<void(discordpp::ActivityInvite invite)>
 Callback function for Client::SetActivityInviteCallback.
 
using ActivityJoinCallback = std::function<void(std::string joinSecret)>
 Callback function for Client::SetActivityJoinCallback.
 
using UpdateStatusCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for when Client::SetOnlineStatus completes.
 
using UpdateRichPresenceCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for when Client::UpdateRichPresence completes.
 
using UpdateRelationshipCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for most other Relationship functions such as Client::SendDiscordFriendRequestById.
 
using SendFriendRequestCallback = std::function<void(discordpp::ClientResult result)>
 Callback function for Client::SendDiscordFriendRequest and Client::SendGameFriendRequest.
 
using RelationshipCreatedCallback
 Callback function for Client::SetRelationshipCreatedCallback.
 
using RelationshipDeletedCallback
 Callback function for Client::SetRelationshipDeletedCallback.
 
using GetDiscordClientConnectedUserCallback
 Callback function for when Client::GetDiscordClientConnectedUser completes.
 
using UserUpdatedCallback = std::function<void(uint64_t userId)>
 Callback function for Client::SetUserUpdatedCallback.
 

Static Public Member Functions

static std::string ErrorToString (discordpp::Client::Error type)
 Converts the Error enum to a string.
 
static std::string GetDefaultAudioDeviceId ()
 Returns the ID of the system default audio device if the user has not explicitly chosen one.
 
static std::string GetDefaultCommunicationScopes ()
 Returns the default set of OAuth2 scopes that should be used with the Discord SDK when making use of the full SDK capabilities, including communications-related features (e.g. user DMs, lobbies, voice chat). If your application does not make use of these features, you should use Client::GetDefaultPresenceScopes instead.
 
static std::string GetDefaultPresenceScopes ()
 Returns the default set of OAuth2 scopes that should be used with the Discord SDK when leveraging baseline presence-related features (e.g. friends list, rich presence, provisional accounts, activity invites). If your application is using communications-related features, which are currently available in limited access, you should use Client::GetDefaultCommunicationScopes instead.
 
static std::string GetVersionHash ()
 Returns the git commit hash this version was built from.
 
static int32_t GetVersionMajor ()
 Returns the major version of the Discord Social SDK.
 
static int32_t GetVersionMinor ()
 Returns the minor version of the Discord Social SDK.
 
static int32_t GetVersionPatch ()
 Returns the patch version of the Discord Social SDK.
 
static std::string StatusToString (discordpp::Client::Status type)
 Converts the Status enum to a string.
 
static std::string ThreadToString (discordpp::Client::Thread type)
 Converts the Thread enum to a string.
 

Static Public Attributes

static const Client nullobj
 Uninitialized instance of Client.
 

Member Typedef Documentation

◆ AcceptActivityInviteCallback

Initial value:
std::function<void(discordpp::ClientResult result, std::string joinSecret)>
Struct that stores information about the result of an SDK function call.
Definition discordpp.h:1294

Callback function for Client::AcceptActivityInvite.

◆ ActivityInviteCallback

Callback function for Client::SetActivityInviteCallback.

◆ ActivityJoinCallback

using discordpp::Client::ActivityJoinCallback = std::function<void(std::string joinSecret)>

Callback function for Client::SetActivityJoinCallback.

◆ AuthorizationCallback

Initial value:
std::function<
void(discordpp::ClientResult result, std::string code, std::string redirectUri)>

Callback invoked when the Authorize function completes.

The first arg contains any error message encountered during the authorization flow, such as if the user cancelled the authorization. The second arg, code, contains an authorization code. This alone cannot be used to authorize with Discord, and instead must be exchanged for an access token later.

◆ AuthorizeDeviceScreenClosedCallback

◆ CreateOrJoinLobbyCallback

Initial value:
std::function<void(discordpp::ClientResult result, uint64_t lobbyId)>

Callback function for Client::CreateOrJoinLobby.

◆ DeleteUserMessageCallback

Callback function for Client::DeleteUserMessage.

◆ DeviceChangeCallback

Initial value:
std::function<void(std::vector<discordpp::AudioDevice> inputDevices,
std::vector<discordpp::AudioDevice> outputDevices)>

Callback function for Client::SetDeviceChangeCallback.

◆ EditUserMessageCallback

Callback function for Client::EditUserMessage.

◆ EndCallCallback

using discordpp::Client::EndCallCallback = std::function<void()>

Callback invoked when Client::EndCall completes.

◆ EndCallsCallback

using discordpp::Client::EndCallsCallback = std::function<void()>

Callback invoked when Client::EndCalls completes.

◆ FetchCurrentUserCallback

Initial value:
std::function<void(discordpp::ClientResult result, uint64_t id, std::string name)>

Callback function for Client::FetchCurrentUser.

◆ GetCurrentInputDeviceCallback

◆ GetCurrentOutputDeviceCallback

◆ GetDiscordClientConnectedUserCallback

Initial value:
std::function<void(discordpp::ClientResult result,
std::optional<discordpp::UserHandle> user)>

Callback function for when Client::GetDiscordClientConnectedUser completes.

◆ GetGuildChannelsCallback

Initial value:
std::function<void(discordpp::ClientResult result,
std::vector<discordpp::GuildChannel> guildChannels)>

Callback function for Client::GetGuildChannels.

◆ GetInputDevicesCallback

Initial value:
std::function<void(std::vector<discordpp::AudioDevice> devices)>

Callback function for Client::GetInputDevices.

◆ GetOutputDevicesCallback

Initial value:
std::function<void(std::vector<discordpp::AudioDevice> devices)>

Callback function for Client::GetOutputDevices.

◆ GetUserGuildsCallback

Initial value:
std::function<void(discordpp::ClientResult result,
std::vector<discordpp::GuildMinimal> guilds)>

Callback function for Client::GetUserGuilds.

◆ LeaveLobbyCallback

Callback function for Client::LeaveLobby.

◆ LinkOrUnlinkChannelCallback

◆ LobbyCreatedCallback

using discordpp::Client::LobbyCreatedCallback = std::function<void(uint64_t lobbyId)>

Callback function for Client::SetLobbyCreatedCallback.

◆ LobbyDeletedCallback

using discordpp::Client::LobbyDeletedCallback = std::function<void(uint64_t lobbyId)>

Callback function for Client::SetLobbyDeletedCallback.

◆ LobbyMemberAddedCallback

using discordpp::Client::LobbyMemberAddedCallback = std::function<void(uint64_t lobbyId, uint64_t memberId)>

Callback function for Client::SetLobbyMemberAddedCallback.

◆ LobbyMemberRemovedCallback

using discordpp::Client::LobbyMemberRemovedCallback = std::function<void(uint64_t lobbyId, uint64_t memberId)>

Callback function for Client::SetLobbyMemberRemovedCallback.

◆ LobbyMemberUpdatedCallback

using discordpp::Client::LobbyMemberUpdatedCallback = std::function<void(uint64_t lobbyId, uint64_t memberId)>

Callback function for Client::SetLobbyMemberUpdatedCallback.

◆ LobbyUpdatedCallback

using discordpp::Client::LobbyUpdatedCallback = std::function<void(uint64_t lobbyId)>

Callback function for Client::SetLobbyUpdatedCallback.

◆ LogCallback

Initial value:
std::function<void(std::string message, discordpp::LoggingSeverity severity)>
LoggingSeverity
Enum that represents the various log levels supported by the SDK.
Definition discordpp.h:579

Callback function invoked when a new log message is generated.

◆ MessageCreatedCallback

using discordpp::Client::MessageCreatedCallback = std::function<void(uint64_t messageId)>

Callback function for Client::SetMessageCreatedCallback.

◆ MessageDeletedCallback

using discordpp::Client::MessageDeletedCallback = std::function<void(uint64_t messageId, uint64_t channelId)>

Callback function for Client::SetMessageDeletedCallback.

◆ MessageUpdatedCallback

using discordpp::Client::MessageUpdatedCallback = std::function<void(uint64_t messageId)>

Callback function for Client::SetMessageUpdatedCallback.

◆ NoAudioInputCallback

using discordpp::Client::NoAudioInputCallback = std::function<void(bool inputDetected)>

Callback function for Client::SetNoAudioInputCallback.

◆ OnStatusChanged

Initial value:
std::function<
void(discordpp::Client::Status status, discordpp::Client::Error error, int32_t errorDetail)>
Status
This enum refers to the status of the internal websocket the SDK uses to communicate with Discord The...
Definition discordpp.h:2951
Error
Represents an error state for the socket connection that the Discord SDK maintains with the Discord b...
Definition discordpp.h:2922

Callback function for Client::SetStatusChangedCallback.

errorDetail will usually be one of the error code described here: https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes

◆ OpenConnectedGamesSettingsInDiscordCallback

Initial value:
std::function<void(discordpp::ClientResult result)>

Callback function for when Client::OpenConnectedGamesSettingsInDiscord completes.

◆ OpenMessageInDiscordCallback

Callback function for when Client::OpenMessageInDiscord completes.

◆ ProvisionalUserMergeRequiredCallback

Callback function for when Client::ProvisionalUserMergeCompleted completes.

◆ RelationshipCreatedCallback

Initial value:
std::function<void(uint64_t userId, bool isDiscordRelationshipUpdate)>

Callback function for Client::SetRelationshipCreatedCallback.

isDiscordRelationshipUpdate will be true if the relationship created with the userId is a Discord relationship, and false if it's an in-game relationship.

◆ RelationshipDeletedCallback

Initial value:
std::function<void(uint64_t userId, bool isDiscordRelationshipUpdate)>

Callback function for Client::SetRelationshipDeletedCallback.

isDiscordRelationshipUpdate will be true if the relationship deleted with the userId is a Discord relationship, and false if it's an in-game relationship.

◆ SendActivityInviteCallback

◆ SendFriendRequestCallback

◆ SendUserMessageCallback

Initial value:
std::function<void(discordpp::ClientResult result, uint64_t messageId)>

This is used for all kinds of 'send message' calls despite the name, to make sure engine bindings use the same delegate type declaration for all of them, which makes things nicer. SendMessageCallback was unavailable because it's a macro on Windows.

◆ SetInputDeviceCallback

Callback function for Client::SetInputDevice.

◆ SetOutputDeviceCallback

Callback function for Client::SetOutputDevice.

◆ TokenExchangeCallback

Initial value:
std::function<void(discordpp::ClientResult result,
std::string accessToken,
std::string refreshToken,
int32_t expiresIn,
std::string scopes)>
AuthorizationTokenType
Represents the type of auth token used by the SDK, either the normal tokens produced by the Discord d...
Definition discordpp.h:549

Callback function for the token exchange APIs such as Client::GetToken.

◆ TokenExpirationCallback

using discordpp::Client::TokenExpirationCallback = std::function<void()>

Callback function for Client::SetTokenExpirationCallback.

◆ UpdateProvisionalAccountDisplayNameCallback

◆ UpdateRelationshipCallback

Callback function for most other Relationship functions such as Client::SendDiscordFriendRequestById.

◆ UpdateRichPresenceCallback

Callback function for when Client::UpdateRichPresence completes.

◆ UpdateStatusCallback

Callback function for when Client::SetOnlineStatus completes.

◆ UpdateTokenCallback

Callback invoked when Client::UpdateToken completes. Once this is done it is safe to call Client::Connect.

◆ UserAudioCapturedCallback

Initial value:
std::function<
void(int16_t* data, uint64_t samplesPerChannel, int32_t sampleRate, uint64_t channels)>

Callback function for Client::StartCallWithAudioCallbacks.

The audio samples in data can be modified in-place to achieve simple DSP effects.

◆ UserAudioReceivedCallback

Initial value:
std::function<void(uint64_t userId,
int16_t* data,
uint64_t samplesPerChannel,
int32_t sampleRate,
uint64_t channels,
bool& outShouldMute)>

Callback function for Client::StartCallWithAudioCallbacks.

The audio samples in data can be modified in-place to achieve simple DSP effects.

◆ UserUpdatedCallback

using discordpp::Client::UserUpdatedCallback = std::function<void(uint64_t userId)>

Callback function for Client::SetUserUpdatedCallback.

◆ VoiceParticipantChangedCallback

Initial value:
std::function<void(uint64_t lobbyId, uint64_t memberId, bool added)>

Callback function for Client::SetVoiceParticipantChangedCallback.

Member Enumeration Documentation

◆ Error

enum class discordpp::Client::Error
strong

Represents an error state for the socket connection that the Discord SDK maintains with the Discord backend.

Generic network failures will use the ConnectionFailed and ConnectionCanceled enum values. Other errors such as if the user's auth token is invalid or out of date will be UnexpectedClose and you should look at the other Error fields for the specific details.

Enumerator
None 

None.

ConnectionFailed 

ConnectionFailed.

UnexpectedClose 

UnexpectedClose.

ConnectionCanceled 

ConnectionCanceled.

◆ Status

enum class discordpp::Client::Status
strong

This enum refers to the status of the internal websocket the SDK uses to communicate with Discord There are ~2 phases for "launching" the client:

  1. The socket has to connect to Discord and exchange an auth token. This is indicated by the Connecting and Connected values.
  2. The socket has to receive an initial payload of data that describes the current user, what lobbies they are in, who their friends are, etc. This is the Ready status. Many Client functions will not work until the status changes to Ready, such as GetCurrentUser().

Status::Ready is the one you want to wait for!

Additionally, sometimes the socket will be disconnected, such as through temporary network blips. But it will try to automatically reconnect, as indicated by the Reconnecting status.

Enumerator
Disconnected 

Disconnected.

Connecting 

Connecting.

Connected 

Connected.

Ready 

Ready.

Reconnecting 

Reconnecting.

Disconnecting 

Disconnecting.

HttpWait 

HttpWait.

◆ Thread

enum class discordpp::Client::Thread
strong

Represents the type of thread to control thread priority on.

Enumerator
Client 

Client.

Voice 

Voice.

Network 

Network.

Constructor & Destructor Documentation

◆ Client() [1/3]

discordpp::Client::Client ( Client && other)
noexcept

Move constructor for Client.

◆ Client() [2/3]

discordpp::Client::Client ( )
explicit

Creates a new instance of the Client.

◆ Client() [3/3]

discordpp::Client::Client ( std::string apiBase,
std::string webBase )
explicit

Creates a new instance of the Client but allows customizing the Discord URL to use.

Member Function Documentation

◆ AbortAuthorize()

void discordpp::Client::AbortAuthorize ( )

This will abort the authorize flow if it is in progress and tear down any associated state.

NOTE: this will not close authorization windows presented to the user.

◆ AbortGetTokenFromDevice()

void discordpp::Client::AbortGetTokenFromDevice ( )

This function is used to abort/cleanup the device authorization flow.

◆ AcceptActivityInvite()

void discordpp::Client::AcceptActivityInvite ( discordpp::ActivityInvite invite,
discordpp::Client::AcceptActivityInviteCallback cb )

Accepts an activity invite that the current user has received.

The given callback will be invoked with the join secret for the activity, which can be used to join the user to the game's internal party system for example. This join secret comes from the other user's rich presence activity.

◆ AcceptDiscordFriendRequest()

void discordpp::Client::AcceptDiscordFriendRequest ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Accepts an incoming Discord friend request from the target user.

Fails if the target user has not sent a Discord friend request to the current user, meaning that the Discord relationship type between the users must be RelationshipType::PendingIncoming.

◆ AcceptGameFriendRequest()

void discordpp::Client::AcceptGameFriendRequest ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Accepts an incoming game friend request from the target user.

Fails if the target user has not sent a game friend request to the current user, meaning that the game relationship type between the users must be RelationshipType::PendingIncoming.

◆ AddLogCallback()

void discordpp::Client::AddLogCallback ( discordpp::Client::LogCallback callback,
discordpp::LoggingSeverity minSeverity )

Adds a callback function to be invoked for each new log message generated by the SDK.

This function explicitly excludes most logs for voice and webrtc activity since those are generally much noisier and you may want to pick a different log level for those. So it will instead include logs for things such as lobbies, relationships, presence, and authentication.

We strongly recommend invoking this function immediately after constructing the Client object.

◆ AddVoiceLogCallback()

void discordpp::Client::AddVoiceLogCallback ( discordpp::Client::LogCallback callback,
discordpp::LoggingSeverity minSeverity )

Adds a callback function to be invoked for each new log message generated by the voice subsystem of the SDK, including the underlying webrtc infrastructure.

We strongly recommend invoking this function immediately after constructing the Client object.

◆ Authorize()

void discordpp::Client::Authorize ( discordpp::AuthorizationArgs args,
discordpp::Client::AuthorizationCallback callback )

Initiates an OAuth2 flow for a user to "sign in with Discord". This flow is intended for desktop and mobile devices. If you are implementing for the console, leverage the device auth flow instead (Client::GetTokenFromDevice or Client::OpenAuthorizeDeviceScreen).

Overview

If you're not familiar with OAuth2, some basic background: At a high level the goal of OAuth2 is to allow a user to connect two applications together and share data between them. In this case, allowing a game to access some of their Discord data. The high level flow is:

  • This function, Authorize, is invoked to start the OAuth2 process, and the user is sent to Discord
  • On Discord, the user sees a prompt to authorize the connection, and that prompt explains what data and functionality the game is requesting.
  • Once the user approves the connection, they are redirected back to your application with a secret code.
  • You can then exchange that secret code to get back an access token which can be used to authenticate with the SDK.

Public vs Confidential Clients

Normal OAuth2 requires a backend server to handle exchanging the "code" for a "token" (the last step mentioned above). Not all games have backend servers or their own identity system though, and for early testing of the SDK that can take some time to setup.

If desired, you can instead change your Discord application in the developer portal (on the OAuth2 tab), to be a "public" client. This will allow you to exchange the code for a token without a backend server, by using the GetToken function below. You can also change this setting back once you have a backend in place later too.

Overlay

To streamline the authentication process, the SDK will attempt to use the Discord overlay if it is enabled. This will allow the user to authenticate without leaving the game, enabling a more seamless experience.

You should check to see if the Discord overlay works with your game before shipping. It's ok if it doesn't though, the SDK will fall back to using a browser window. Once you're ready to ship, you can work with us to have the overlay enabled by default for your game too.

If your game's main window is not the same process that the SDK is running in, then you need to tell the SDK the PID of the window that the overlay should attach to. You can do this by calling Client::SetGameWindowPid.

Redirects

For the Authorize function to work, you must configure a redirect url in your Discord application in the developer portal, (it is located on the OAuth2 tab).

The SDK will then spin up a local webserver to handle the OAuth2 redirects for you as well to streamline your integration.

Security

This function accepts an args object, and two of those values are important for security:

  • To prevent CSRF attacks during auth, the SDK automatically attaches a state and checks it for you when performing the authorization. You can override state if you want for your own flow, but please be mindful to keep it a secure, random value.
  • If you are using the Client::GetToken function you will need to provide a "code challenge" or "code verifier". We'll spare you the boring details of how that works (woo… crypto), as we've made a simple function to create these for you, Client::CreateAuthorizationCodeVerifier. That returns a struct with two items, a challenge value to pass into this function and a verifier value to pass into Client::GetToken.

Callbacks & Code Exchange

When this flow completes, the given callback function will be invoked with a "code". That code must be exchanged for an actual authorization token before it can be used. To start, you can use the Client::GetToken function to perform this exchange. Longer term private apps will want to move to the server side API for this, since that enables provisional accounts to "upgrade" to full Discord accounts.

Android

You must add the appropriate intent filter to your AndroidManifest.xml. AndroidBuildPostProcessor in the sample demonstrates how to do this automatically.

If you'd like to manage it yourself, the required entry in your <application> looks like this:

<activity android:name="com.discord.socialsdk.AuthenticationActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="discord-1234567890123456789" />
</intent-filter>
</activity>

Replace the numbers after discord- with your Application ID from the Discord developer portal.

Android support (specifically the builtin auth flow) requires the androidx.browser library as a dependency of your app. The sample uses Google External Dependency Manager to add this to the Gradle build for the project, but you may use any means of your choosing to add this dependency. We currently depend on version 1.8.0 of this library.

For more information see: https://discord.com/developers/docs/topics/oauth2

◆ BlockUser()

void discordpp::Client::BlockUser ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Blocks the target user so that they cannot send the user friend or activity invites and cannot message them anymore.

Blocking a user will also remove any existing relationship between the two users, and persists across games, so blocking a user in one game or on Discord will block them in all other games and on Discord as well.

◆ CancelDiscordFriendRequest()

void discordpp::Client::CancelDiscordFriendRequest ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Cancels an outgoing Discord friend request to the target user.

Fails if a Discord friend request has not been sent to the target user, meaning that the Discord relationship type between the users must be RelationshipType::PendingOutgoing.

◆ CancelGameFriendRequest()

void discordpp::Client::CancelGameFriendRequest ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Cancels an outgoing game friend request to the target user.

Fails if a game friend request has not been sent to the target user, meaning that the game relationship type between the users must be RelationshipType::PendingOutgoing.

◆ CanOpenMessageInDiscord()

bool discordpp::Client::CanOpenMessageInDiscord ( uint64_t messageId)

Returns true if the given message is able to be viewed in a Discord client.

Not all chat messages are replicated to Discord. For example lobby chat and some DMs are ephemeral and not persisted on Discord so cannot be opened. This function checks those conditions and makes sure the message is viewable in Discord.

◆ ClearRichPresence()

void discordpp::Client::ClearRichPresence ( )

Clears the right presence for the current user.

◆ CloseAuthorizeDeviceScreen()

void discordpp::Client::CloseAuthorizeDeviceScreen ( )

This function is used to hide the device authorization screen and is used for the case where the user is on a limited input device, such as a console or smart TV. This function should be used in conjunction with a backend server to handle the device authorization flow. For a public client, you can use Client::AbortGetTokenFromDevice instead.

◆ Connect()

void discordpp::Client::Connect ( )

Asynchronously connects the client to Discord.

If a client is disconnecting, this will wait for the disconnect before reconnecting. You should use the Client::SetStatusChangedCallback and Client::GetStatus functions to receive updates on the client status. The Client is only safe to use once the status changes to Status::Ready.

◆ CreateAuthorizationCodeVerifier()

discordpp::AuthorizationCodeVerifier discordpp::Client::CreateAuthorizationCodeVerifier ( )

Helper function that can create a code challenge and verifier for use in the Client::Authorize + Client::GetToken flow. This returns a struct with two items, a challenge value to pass into Client::Authorize and a verifier value to pass into GetToken.

◆ CreateOrJoinLobby()

void discordpp::Client::CreateOrJoinLobby ( std::string const & secret,
discordpp::Client::CreateOrJoinLobbyCallback callback )

Joins the user to the specified lobby, creating one if it does not exist.

The lobby is specified by the supplied string, which should be a hard to guess secret generated by the game. All users who join the lobby with the same secret will be placed in the same lobby.

For exchanging the secret, we strongly encourage looking into the activity invite and rich presence systems which provide a way to include a secret string that only accepted party members are able to see.

As with server created lobbies, client created lobbies auto-delete once they have been idle for a few minutes (which currently defaults to 5 minutes). A lobby is idle if no users are connected to it.

This function shouldn't be used for long lived lobbies. The "secret" value expires after ~30 days, at which point the existing lobby cannot be joined and a new one would be created instead.

◆ CreateOrJoinLobbyWithMetadata()

void discordpp::Client::CreateOrJoinLobbyWithMetadata ( std::string const & secret,
std::unordered_map< std::string, std::string > const & lobbyMetadata,
std::unordered_map< std::string, std::string > const & memberMetadata,
discordpp::Client::CreateOrJoinLobbyCallback callback )

Variant of Client::CreateOrJoinLobby that also accepts developer-supplied metadata.

Metadata is just simple string key/value pairs. An example use case for this might be to the internal game ID of the user of each lobby so all members of the lobby can have a mapping of discord IDs to game IDs. Subsequent calls to CreateOrJoinLobby will overwrite the metadata for the lobby and member.

◆ DeleteUserMessage()

void discordpp::Client::DeleteUserMessage ( uint64_t recipientId,
uint64_t messageId,
discordpp::Client::DeleteUserMessageCallback cb )

Deletes the specified message sent by the current user to the specified recipient.

◆ Disconnect()

void discordpp::Client::Disconnect ( )

Asynchronously disconnects the client.

You can leverage Client::SetStatusChangedCallback and Client::GetStatus to receive updates on the client status. It is fully disconnected when the status changes to Client::Status::Disconnected.

◆ EditUserMessage()

void discordpp::Client::EditUserMessage ( uint64_t recipientId,
uint64_t messageId,
std::string const & content,
discordpp::Client::EditUserMessageCallback cb )

Edits the specified message sent by the current user to the specified recipient.

All of the same restrictions apply as for sending a message, see SendUserMessage for more.

◆ EndCall()

void discordpp::Client::EndCall ( uint64_t channelId,
discordpp::Client::EndCallCallback callback )

Ends any active call, if any. Any references you have to Call objects are invalid after they are ended, and can be immediately freed.

◆ EndCalls()

void discordpp::Client::EndCalls ( discordpp::Client::EndCallsCallback callback)

Ends any active call, if any. Any references you have to Call objects are invalid after they are ended, and can be immediately freed.

◆ ErrorToString()

static std::string discordpp::Client::ErrorToString ( discordpp::Client::Error type)
static

Converts the Error enum to a string.

◆ FetchCurrentUser()

void discordpp::Client::FetchCurrentUser ( discordpp::AuthorizationTokenType tokenType,
std::string const & token,
discordpp::Client::FetchCurrentUserCallback callback )

Fetches basic information about the user associated with the given auth token.

This can allow you to check if an auth token is valid or not. This does not require the client to be connected or to have it's own authentication token, so it can be called immediately after the client connects.

◆ GetApplicationId()

uint64_t discordpp::Client::GetApplicationId ( )

This function is used to get the application ID for the client. This is used to identify the application to the Discord client. This is used for things like authentication, rich presence, and activity invites when not connected with Client::Connect. When calling Client::Connect, the application ID is set automatically.

◆ GetCall()

discordpp::Call discordpp::Client::GetCall ( uint64_t channelId)

Returns a reference to the currently active call, if any.

◆ GetCalls()

std::vector< discordpp::Call > discordpp::Client::GetCalls ( )

Returns a reference to all currently active calls, if any.

◆ GetChannelHandle()

std::optional< discordpp::ChannelHandle > discordpp::Client::GetChannelHandle ( uint64_t channelId) const

Returns a reference to the Discord channel object for the given ID.

All messages in Discord are sent in a channel, so the most common use for this will be to look up the channel a message was sent in. For convience this API will also work with lobbies, so the three possible return values for the SDK are a DM, an Ephemeral DM, and a Lobby.

◆ GetCurrentInputDevice()

void discordpp::Client::GetCurrentInputDevice ( discordpp::Client::GetCurrentInputDeviceCallback cb)

Asynchronously fetches the current audio input device in use by the client.

◆ GetCurrentOutputDevice()

void discordpp::Client::GetCurrentOutputDevice ( discordpp::Client::GetCurrentOutputDeviceCallback cb)

Asynchronously fetches the current audio output device in use by the client.

◆ GetCurrentUser()

discordpp::UserHandle discordpp::Client::GetCurrentUser ( ) const

Returns the user associated with the current client.

Must not be called before the Client::GetStatus has changed to Status::Ready. If the client has disconnected, or is in the process of reconnecting, it will return the previous value of the user, even if the auth token has changed since then. Wait for client.GetStatus() to change to Ready before accessing it again.

◆ GetDefaultAudioDeviceId()

static std::string discordpp::Client::GetDefaultAudioDeviceId ( )
static

Returns the ID of the system default audio device if the user has not explicitly chosen one.

◆ GetDefaultCommunicationScopes()

static std::string discordpp::Client::GetDefaultCommunicationScopes ( )
static

Returns the default set of OAuth2 scopes that should be used with the Discord SDK when making use of the full SDK capabilities, including communications-related features (e.g. user DMs, lobbies, voice chat). If your application does not make use of these features, you should use Client::GetDefaultPresenceScopes instead.

Communications-related features are currently in limited access and are not available to all applications, however, they can be demoed in limited capacity by all applications. If you are interested in using these features in your game, please reach out to the Discord team.

It's ok to further customize your requested oauth2 scopes to add additional scopes if you have legitimate usages for them. However, we strongly recommend always using Client::GetDefaultCommunicationScopes or Client::GetDefaultPresenceScopes as a baseline to enable a better authorization experience for users!

◆ GetDefaultPresenceScopes()

static std::string discordpp::Client::GetDefaultPresenceScopes ( )
static

Returns the default set of OAuth2 scopes that should be used with the Discord SDK when leveraging baseline presence-related features (e.g. friends list, rich presence, provisional accounts, activity invites). If your application is using communications-related features, which are currently available in limited access, you should use Client::GetDefaultCommunicationScopes instead.

It's ok to further customize your requested oauth2 scopes to add additional scopes if you have legitimate usages for them. However, we strongly recommend always using Client::GetDefaultCommunicationScopes or Client::GetDefaultPresenceScopes as a baseline to enable a better authorization experience for users!

◆ GetDiscordClientConnectedUser()

void discordpp::Client::GetDiscordClientConnectedUser ( uint64_t applicationId,
discordpp::Client::GetDiscordClientConnectedUserCallback callback ) const

If the Discord app is running on the user's computer and the SDK establishes a connection to it, this function will return the user that is currently logged in to the Discord app.

◆ GetGuildChannels()

void discordpp::Client::GetGuildChannels ( uint64_t guildId,
discordpp::Client::GetGuildChannelsCallback cb )

Fetches all of the channels that the current user can access in the given guild.

The purpose of this is to power the channel linking flow for linking a Discord channel to an in-game lobby. So this function can be used to power a UI to let the user pick which channel to link to once they have picked a guild. See the docs on LobbyHandle for more information.

◆ GetInputDevices()

void discordpp::Client::GetInputDevices ( discordpp::Client::GetInputDevicesCallback cb)

Asynchronously fetches the list of audio input devices available to the user.

◆ GetInputVolume()

float discordpp::Client::GetInputVolume ( )

Returns the input volume for the current user's microphone.

Input volume is specified as a percentage in the range [0, 100] which represents the perceptual loudness.

◆ GetLobbyHandle()

std::optional< discordpp::LobbyHandle > discordpp::Client::GetLobbyHandle ( uint64_t lobbyId) const

Returns a reference to the Discord lobby object for the given ID.

◆ GetLobbyIds()

std::vector< uint64_t > discordpp::Client::GetLobbyIds ( ) const

Returns a list of all the lobbies that the user is a member of and the SDK has loaded.

Lobbies are optimistically loaded when the SDK starts but in some cases may not be available immediately after the SDK status changes to Status::Ready.

◆ GetMessageHandle()

std::optional< discordpp::MessageHandle > discordpp::Client::GetMessageHandle ( uint64_t messageId) const

Returns a reference to the Discord message object for the given ID.

The SDK keeps the 25 most recent messages in each channel in memory. Messages sent before the SDK was started cannot be accessed with this.

◆ GetOutputDevices()

void discordpp::Client::GetOutputDevices ( discordpp::Client::GetOutputDevicesCallback cb)

Asynchronously fetches the list of audio output devices available to the user.

◆ GetOutputVolume()

float discordpp::Client::GetOutputVolume ( )

Returns the output volume for the current user.

Output volume specified as a percentage in the range [0, 200] which represents the perceptual loudness.

◆ GetProvisionalToken()

void discordpp::Client::GetProvisionalToken ( uint64_t applicationId,
discordpp::AuthenticationExternalAuthType externalAuthType,
std::string const & externalAuthToken,
discordpp::Client::TokenExchangeCallback callback )

Provisional accounts are a way for users that have not signed up for Discord to still access SDK functionality. They are "placeholder" Discord accounts for the user that are owned and managed by your game. Provisional accounts exist so that your users can engage with Discord APIs and systems without the friction of creating their own Discord account. Provisional accounts and their data are unique per Discord application.

This function generates a Discord access token. You pass in the "identity" of the user, and it generates a new Discord account that is tied to that identity. There are multiple ways of specifying that identity, including using Steam/Epic services, or using your own identity system.

The callback function will be invoked with an access token that expires in 1 hour. Refresh tokens are not supported for provisional accounts, so that will be an empty string. You will need to call this function again to get a new access token when the old one expires.

NOTE: When the token expires the SDK will still continue to receive updates such as new messages sent in a lobby, and any voice calls will continue to be active. But any new actions taken will fail such as sending a messaging or adding a friend. You can get a new token and pass it to UpdateToken without interrupting the user's experience.

It is suggested that these provisional tokens are not stored, and instead to just invoke this function each time the game is launched and when these tokens are about to expire. However, should you choose to store it, it is recommended to differentiate these provisional account tokens from "full" Discord account tokens.

NOTE: This function only works for public clients. Public clients are ones that do not have a backend server or their own concept of user accounts and simply rely on a separate system for authentication like Steam/Epic.

When first testing the SDK, it can be a lot easier to use a public client to get a proof of concept going, and change it to a confidential client later. You can toggle that setting on the OAuth2 page for your application in the Discord developer portal, https://discord.com/developers/applications

◆ GetRelationshipHandle()

discordpp::RelationshipHandle discordpp::Client::GetRelationshipHandle ( uint64_t userId) const

Returns the RelationshipHandle that corresponds to the relationship between the current user and the given user.

◆ GetRelationships()

std::vector< discordpp::RelationshipHandle > discordpp::Client::GetRelationships ( ) const

Returns a list of all of the relationships the current user has with others, including all Discord relationships and all Game relationships for the current game.

◆ GetSelfDeafAll()

bool discordpp::Client::GetSelfDeafAll ( ) const

Returns whether the current user is deafened in all calls.

◆ GetSelfMuteAll()

bool discordpp::Client::GetSelfMuteAll ( ) const

Returns whether the current user's microphone is muted in all calls.

◆ GetStatus()

discordpp::Client::Status discordpp::Client::GetStatus ( ) const

Returns the current status of the client, see the Status enum for an explanation of the possible values.

◆ GetToken()

void discordpp::Client::GetToken ( uint64_t applicationId,
std::string const & code,
std::string const & codeVerifier,
std::string const & redirectUri,
discordpp::Client::TokenExchangeCallback callback )

Exchanges an authorization code that was returned from the Client::Authorize function for an access token which can be used to authenticate with the SDK.

The callback function will be invoked with two tokens:

  • An access token which can be used to authenticate with the SDK, but expires after 7 days.
  • A refresh token, which cannot be used to authenticate, but can be used to get a new access token later. Refresh tokens do not currently expire.

It will also include when the access token expires in seconds. You will want to store this value as well and refresh the token when it gets close to expiring (for example if the user launches the game and the token expires within 24 hours, it would be good to refresh it).

For more information see https://discord.com/developers/docs/topics/oauth2

NOTE: This function only works for public clients. Public clients are ones that do not have a backend server or their own concept of user accounts and simply rely on a separate system for authentication like Steam/Epic.

When first testing the SDK, it can be a lot easier to use a public client to get a proof of concept going, and change it to a confidential client later. You can toggle that setting on the OAuth2 page for your application in the Discord developer portal, https://discord.com/developers/applications

◆ GetTokenFromDevice()

void discordpp::Client::GetTokenFromDevice ( discordpp::DeviceAuthorizationArgs args,
discordpp::Client::TokenExchangeCallback callback )

This function is a combination of Client::Authorize and Client::GetToken, but is used for the case where the user is on a limited input device, such as a console or smart TV.

The callback function will be invoked with two tokens:

  • An access token which can be used to authenticate with the SDK, but expires after 7 days.
  • A refresh token, which cannot be used to authenticate, but can be used to get a new access token later. Refresh tokens do not currently expire.

It will also include when the access token expires in seconds. You will want to store this value as well and refresh the token when it gets close to expiring (for example if the user launches the game and the token expires within 24 hours, it would be good to refresh it).

For more information see https://discord.com/developers/docs/topics/oauth2

NOTE: This function only works for public clients. Public clients are ones that do not have a backend server or their own concept of user accounts and simply rely on a separate system for authentication like Steam/Epic. If you have a backend server for auth, you can use Client::OpenAuthorizeDeviceScreen and Client::CloseAuthorizeDeviceScreen to show/hide the UI for the device auth flow.

When first testing the SDK, it can be a lot easier to use a public client to get a proof of concept going, and change it to a confidential client later. You can toggle that setting on the OAuth2 page for your application in the Discord developer portal, https://discord.com/developers/applications

◆ GetTokenFromDeviceProvisionalMerge()

void discordpp::Client::GetTokenFromDeviceProvisionalMerge ( discordpp::DeviceAuthorizationArgs args,
discordpp::AuthenticationExternalAuthType externalAuthType,
std::string const & externalAuthToken,
discordpp::Client::TokenExchangeCallback callback )

This function is a combination of Client::Authorize and Client::GetTokenFromProvisionalMerge, but is used for the case where the user is on a limited input device, such as a console or smart TV.

This function should be used whenever a user with a provisional account wants to link to an existing Discord account or "upgrade" their provisional account into a "full" Discord account.

In this case, data from the provisional account should be "migrated" to the Discord account, a process we call "account merging". Specifically relationships, DMs, and lobby memberships are transferred to the Discord account.

The provisional account will be deleted once this merging process completes. If the user later unlinks, then a new provisional account with a new unique ID is created.

The account merging process starts the same as the normal login flow, by invoking the GetTokenFromDevice. But instead of calling GetTokenFromDevice, call this function and pass in the provisional user's identity as well.

The Discord backend can then find both the provisional account with that identity and the new Discord account and merge any data as necessary.

See the documentation for GetTokenFromDevice for more details on the callback. Note that the callback will be invoked when the token exchange completes, but the process of merging accounts happens asynchronously so will not be complete yet.

NOTE: This function only works for public clients. Public clients are ones that do not have a backend server or their own concept of user accounts and simply rely on a separate system for authentication like Steam/Epic. If you have a backend server for auth, you can use Client::OpenAuthorizeDeviceScreen and Client::CloseAuthorizeDeviceScreen to show/hide the UI for the device auth flow.

When first testing the SDK, it can be a lot easier to use a public client to get a proof of concept going, and change it to a confidential client later. You can toggle that setting on the OAuth2 page for your application in the Discord developer portal, https://discord.com/developers/applications

◆ GetTokenFromProvisionalMerge()

void discordpp::Client::GetTokenFromProvisionalMerge ( uint64_t applicationId,
std::string const & code,
std::string const & codeVerifier,
std::string const & redirectUri,
discordpp::AuthenticationExternalAuthType externalAuthType,
std::string const & externalAuthToken,
discordpp::Client::TokenExchangeCallback callback )

This function should be used with the Client::Authorize function whenever a user with a provisional account wants to link to an existing Discord account or "upgrade" their provisional account into a "full" Discord account.

In this case, data from the provisional account should be "migrated" to the Discord account, a process we call "account merging". Specifically relationships, DMs, and lobby memberships are transferred to the Discord account.

The provisional account will be deleted once this merging process completes. If the user later unlinks, then a new provisional account with a new unique ID is created.

The account merging process starts the same as the normal login flow, by invoking the Authorize method to get an authorization code back. But instead of calling GetToken, call this function and pass in the provisional user's identity as well.

The Discord backend can then find both the provisional account with that identity and the new Discord account and merge any data as necessary.

See the documentation for GetToken for more details on the callback. Note that the callback will be invoked when the token exchange completes, but the process of merging accounts happens asynchronously so will not be complete yet.

NOTE: This function only works for public clients. Public clients are ones that do not have a backend server or their own concept of user accounts and simply rely on a separate system for authentication like Steam/Epic.

When first testing the SDK, it can be a lot easier to use a public client to get a proof of concept going, and change it to a confidential client later. You can toggle that setting on the OAuth2 page for your application in the Discord developer portal, https://discord.com/developers/applications

◆ GetUser()

std::optional< discordpp::UserHandle > discordpp::Client::GetUser ( uint64_t userId) const

Returns the UserHandle associated with the given user ID.

It will not fetch a user from Discord's API if it is not available. Generally you can trust that users will be available for all relationships and for the authors of any messages received.

◆ GetUserGuilds()

void discordpp::Client::GetUserGuilds ( discordpp::Client::GetUserGuildsCallback cb)

Fetches all of the guilds (also known as Discord servers) that the current user is a member of.

The purpose of this is to power the channel linking flow for linking a Discord channel to an in-game lobby. So this function can be used to power a UI to let the user which guild to link to. See the docs on LobbyHandle for more information.

◆ GetVersionHash()

static std::string discordpp::Client::GetVersionHash ( )
static

Returns the git commit hash this version was built from.

◆ GetVersionMajor()

static int32_t discordpp::Client::GetVersionMajor ( )
static

Returns the major version of the Discord Social SDK.

◆ GetVersionMinor()

static int32_t discordpp::Client::GetVersionMinor ( )
static

Returns the minor version of the Discord Social SDK.

◆ GetVersionPatch()

static int32_t discordpp::Client::GetVersionPatch ( )
static

Returns the patch version of the Discord Social SDK.

◆ IsAuthenticated()

bool discordpp::Client::IsAuthenticated ( )

Returns true if the SDK has a non-empty OAuth2 token set, regardless of whether that token is valid or not.

◆ LeaveLobby()

void discordpp::Client::LeaveLobby ( uint64_t lobbyId,
discordpp::Client::LeaveLobbyCallback callback )

Removes the current user from the specified lobby.

Only lobbies that contain a "secret" can be left. In other words, only lobbies created with Client::CreateOrJoinLobby can be left. Lobbies created using the server API may not be manipulated by clients, so you must use the server API to remove them too.

◆ LinkChannelToLobby()

void discordpp::Client::LinkChannelToLobby ( uint64_t lobbyId,
uint64_t channelId,
discordpp::Client::LinkOrUnlinkChannelCallback callback )

Links the specified channel on Discord to the specified in-game lobby.

Any message sent in one will be copied over to the other! See the docs on LobbyHandle for more information.

◆ OpenAuthorizeDeviceScreen()

void discordpp::Client::OpenAuthorizeDeviceScreen ( uint64_t clientId,
std::string const & userCode )

This function is used to show the device authorization screen and is used for the case where the user is on a limited input device, such as a console or smart TV. This function should be used in conjunction with a backend server to handle the device authorization flow. For a public client, you can use Client::GetTokenFromDevice instead.

◆ OpenConnectedGamesSettingsInDiscord()

void discordpp::Client::OpenConnectedGamesSettingsInDiscord ( discordpp::Client::OpenConnectedGamesSettingsInDiscordCallback callback)

Opens the Connected Games settings in the Discord client, which is where users can manage their settings related to games using the Discord Social SDK.

If the client isn't connected or the user is a provisional account, this function does nothing.

It is always a no-op for console platforms.

◆ OpenMessageInDiscord()

void discordpp::Client::OpenMessageInDiscord ( uint64_t messageId,
discordpp::Client::ProvisionalUserMergeRequiredCallback provisionalUserMergeRequiredCallback,
discordpp::Client::OpenMessageInDiscordCallback callback )

Opens the given message in the Discord client.

This is useful when a message is sent that contains content that cannot be viewed in Discord. You can call this function in the click handler for any CTA you show to view the message in Discord.

◆ operator bool()

discordpp::Client::operator bool ( ) const
inline

Returns true if the instance contains a valid object.

◆ operator=()

Client & discordpp::Client::operator= ( Client && other)
noexcept

Move assignment operator for Client.

◆ ProvisionalUserMergeCompleted()

void discordpp::Client::ProvisionalUserMergeCompleted ( bool success)

Some functions don't work for provisional accounts, and require the user merge their account into a full Discord account before proceeding. This callback is invoked when an account merge must take place before proceeding. The developer is responsible for initiating the account merge, and then calling Client::ProvisionalUserMergeCompleted to signal to the SDK that the pending operation can continue with the new account.

◆ RefreshToken()

void discordpp::Client::RefreshToken ( uint64_t applicationId,
std::string const & refreshToken,
discordpp::Client::TokenExchangeCallback callback )

Generates a new access token for the current user from a refresh token.

Once this is called, the old access and refresh tokens are both invalidated and cannot be used again. The callback function will be invoked with a new access and refresh token. See GetToken for more details.

NOTE: This function only works for public clients. Public clients are ones that do not have a backend server or their own concept of user accounts and simply rely on a separate system for authentication like Steam/Epic.

When first testing the SDK, it can be a lot easier to use a public client to get a proof of concept going, and change it to a confidential client later. You can toggle that setting on the OAuth2 page for your application in the Discord developer portal, https://discord.com/developers/applications

◆ RegisterLaunchCommand()

bool discordpp::Client::RegisterLaunchCommand ( uint64_t applicationId,
std::string command )

When a user accepts an activity invite for your game within the Discord client, Discord needs to know how to launch the game for that user. This function allows you to register a command that Discord will run to launch your game. You should invoke this when the SDK starts up so that if the user in the future tries to join from Discord the game will be able to be launched for them. Returns true if the command was successfully registered, false otherwise.

On Windows and Linux, this command should be a path to an executable. It also supports any launch parameters that may be needed, like "C:\path\to my\game.exe" –full-screen –no-hax If you pass an empty string in for the command, the SDK will register the current running executable. To launch the game from a custom protocol like my-awesome-game://, pass that in as an argument of the executable that should be launched by that protocol. For example, "C:\path\to my\game.exe" my-awesome-game://

On macOS, due to the way Discord registers executables, your game needs to be bundled for this command to work. That means it should be a .app. You can pass a custom protocol like my-awesome-game:// as the custom command, but not a path to an executable. If you pass an empty string in for the command, the SDK will register the current running bundle, if any.

◆ RegisterLaunchSteamApplication()

bool discordpp::Client::RegisterLaunchSteamApplication ( uint64_t applicationId,
uint32_t steamAppId )

When a user accepts an activity invite for your game within the Discord client, Discord needs to know how to launch the game for that user. For steam games, this function allows you to indicate to Discord what the steam game ID is. You should invoke this when the SDK starts up so that if the user in the future tries to join from Discord the game will be able to be launched for them. Returns true if the command was successfully registered, false otherwise.

◆ RejectDiscordFriendRequest()

void discordpp::Client::RejectDiscordFriendRequest ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Declines an incoming Discord friend request from the target user.

Fails if the target user has not sent a Discord friend request to the current user, meaning that the Discord relationship type between the users must be RelationshipType::PendingIncoming.

◆ RejectGameFriendRequest()

void discordpp::Client::RejectGameFriendRequest ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Declines an incoming game friend request from the target user.

Fails if the target user has not sent a game friend request to the current user, meaning that the game relationship type between the users must be RelationshipType::PendingIncoming.

◆ RemoveDiscordAndGameFriend()

void discordpp::Client::RemoveDiscordAndGameFriend ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Removes any friendship between the current user and the target user. This function will remove BOTH any Discord friendship and any game friendship between the users.

Fails if the target user is not currently a Discord OR game friend with the current user.

◆ RemoveGameFriend()

void discordpp::Client::RemoveGameFriend ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Removes any game friendship between the current user and the target user.

Fails if the target user is not currently a game friend with the current user.

◆ SearchFriendsByUsername()

std::vector< discordpp::UserHandle > discordpp::Client::SearchFriendsByUsername ( std::string searchStr) const

Searches all of your friends by both username and display name, returning a list of all friends that match the search string.

Under the hood uses the Levenshtein distance algorithm.

◆ SendActivityInvite()

void discordpp::Client::SendActivityInvite ( uint64_t userId,
std::string const & content,
discordpp::Client::SendActivityInviteCallback cb )

Sends a Discord activity invite to the specified user.

The invite is sent as a message on Discord, which means it can be sent in the following situations:

  • Both users are online and in the game and have not blocked each other
  • Both users are friends with each other
  • Both users share a mutual Discord server and have previously DM'd each other on Discord

You can optionally include some message content to include in the message containing the invite, but it's ok to pass an empty string too.

◆ SendActivityJoinRequest()

void discordpp::Client::SendActivityJoinRequest ( uint64_t userId,
discordpp::Client::SendActivityInviteCallback cb )

Requests to join the activity of the specified user.

This can be called whenever the target user has a rich presence activity for the current game and that activity has space for another user to join them.

That user will basically receive an activity invite which they can accept or reject.

◆ SendActivityJoinRequestReply()

void discordpp::Client::SendActivityJoinRequestReply ( discordpp::ActivityInvite invite,
discordpp::Client::SendActivityInviteCallback cb )

When another user requests to join the current user's party, this function is called to to allow that user to join. Specifically this will send the original user an activity invite which they then need to accept again.

◆ SendDiscordFriendRequest()

void discordpp::Client::SendDiscordFriendRequest ( std::string const & username,
discordpp::Client::SendFriendRequestCallback cb )

Sends a Discord friend request to the target user.

The target user is identified by their Discord unique username (not their DisplayName).

After the friend request is sent, each user will have a new Discord relationship created. For the current user the RelationshipHandle::DiscordRelationshipType will be RelationshipType::PendingOutgoing and for the target user it will be RelationshipType::PendingIncoming.

If the current user already has received a Discord friend request from the target user (meaning RelationshipHandle::DiscordRelationshipType is RelationshipType::PendingIncoming), then the two users will become Discord friends.

See RelationshipHandle for more information on the difference between Discord and Game relationships.

◆ SendDiscordFriendRequestById()

void discordpp::Client::SendDiscordFriendRequestById ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Sends a Discord friend request to the target user.

The target user is identified by their Discord ID.

After the friend request is sent, each user will have a new Discord relationship created. For the current user the RelationshipHandle::DiscordRelationshipType will be RelationshipType::PendingOutgoing and for the target user it will be RelationshipType::PendingIncoming.

If the current user already has received a Discord friend request from the target user (meaning RelationshipHandle::DiscordRelationshipType is RelationshipType::PendingIncoming), then the two users will become Discord friends.

See RelationshipHandle for more information on the difference between Discord and Game relationships.

◆ SendGameFriendRequest()

void discordpp::Client::SendGameFriendRequest ( std::string const & username,
discordpp::Client::SendFriendRequestCallback cb )

Sends (or accepts) a game friend request to the target user.

The target user is identified by their Discord unique username (not their DisplayName).

After the friend request is sent, each user will have a new game relationship created. For the current user the RelationshipHandle::GameRelationshipType will be RelationshipType::PendingOutgoing and for the target user it will be RelationshipType::PendingIncoming.

If the current user already has received a game friend request from the target user (meaning RelationshipHandle::GameRelationshipType is RelationshipType::PendingIncoming), then the two users will become game friends.

See RelationshipHandle for more information on the difference between Discord and Game relationships.

◆ SendGameFriendRequestById()

void discordpp::Client::SendGameFriendRequestById ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Sends (or accepts) a game friend request to the target user.

The target user is identified by their Discord ID.

After the friend request is sent, each user will have a new game relationship created. For the current user the RelationshipHandle::GameRelationshipType will be RelationshipType::PendingOutgoing and for the target user it will be RelationshipType::PendingIncoming.

If the current user already has received a game friend request from the target user (meaning RelationshipHandle::GameRelationshipType is RelationshipType::PendingIncoming), then the two users will become game friends.

See RelationshipHandle for more information on the difference between Discord and Game relationships.

◆ SendLobbyMessage()

void discordpp::Client::SendLobbyMessage ( uint64_t lobbyId,
std::string const & content,
discordpp::Client::SendUserMessageCallback cb )

Sends a message in a lobby chat to all members of the lobby.

The content of the message is restricted to 2,000 characters maximum. See https://discord.com/developers/docs/resources/message for more details.

The content of the message can also contain special markup for formatting if desired, see https://discord.com/developers/docs/reference#message-formatting for more details.

If the lobby is linked to a channel, the message will also be sent to that channel on Discord.

◆ SendLobbyMessageWithMetadata()

void discordpp::Client::SendLobbyMessageWithMetadata ( uint64_t lobbyId,
std::string const & content,
std::unordered_map< std::string, std::string > const & metadata,
discordpp::Client::SendUserMessageCallback cb )

Variant of Client::SendLobbyMessage that also accepts metadata to be sent with the message.

Metadata is just simple string key/value pairs. An example use case for this might be to include the name of the character that sent a message.

◆ SendUserMessage()

void discordpp::Client::SendUserMessage ( uint64_t recipientId,
std::string const & content,
discordpp::Client::SendUserMessageCallback cb )

Sends a direct message to the specified user.

The content of the message is restricted to 2,000 characters maximum. See https://discord.com/developers/docs/resources/message for more details.

The content of the message can also contain special markup for formatting if desired, see https://discord.com/developers/docs/reference#message-formatting for more details.

A message can be sent between two users in the following situations:

  • Both users are online and in the game and have not blocked each other
  • Both users are friends with each other
  • Both users share a mutual Discord server and have previously DM'd each other on Discord

◆ SendUserMessageWithMetadata()

void discordpp::Client::SendUserMessageWithMetadata ( uint64_t recipientId,
std::string const & content,
std::unordered_map< std::string, std::string > const & metadata,
discordpp::Client::SendUserMessageCallback cb )

Variant of Client::SendUserMessage that also accepts metadata to be sent with the message.

Metadata is just simple string key/value pairs. An example use case for this might be to include the name of the character that sent a message.

◆ SetActivityInviteCreatedCallback()

void discordpp::Client::SetActivityInviteCreatedCallback ( discordpp::Client::ActivityInviteCallback cb)

Sets a callback function that is invoked when the current user receives an activity invite from another user.

These invites are always sent as messages, so the SDK is parsing these messages to look for invites and invokes this callback instead. The message create callback will not be invoked for these messages. The invite object contains all the necessary information to identity the invite, which you can later pass to Client::AcceptActivityInvite.

◆ SetActivityInviteUpdatedCallback()

void discordpp::Client::SetActivityInviteUpdatedCallback ( discordpp::Client::ActivityInviteCallback cb)

Sets a callback function that is invoked when an existing activity invite changes. Currently, the only thing that changes on an activity invite is its validity. If the sender goes offline or exits the party the receiver was invited to, the invite is no longer joinable. It is possible for an invalid invite to go from invalid to valid if the sender rejoins the activity.

◆ SetActivityJoinCallback()

void discordpp::Client::SetActivityJoinCallback ( discordpp::Client::ActivityJoinCallback cb)

Sets a callback function that is invoked when the current user also has Discord running on their computer and they accept an activity invite in the Discord client.

This callback is invoked with the join secret from the activity rich presence, which you can use to join them to the game's internal party system. See Activity for more information on invites.

◆ SetApplicationId()

void discordpp::Client::SetApplicationId ( uint64_t applicationId)

This function is used to set the application ID for the client. This is used to identify the application to the Discord client. This is used for things like authentication, rich presence, and activity invites when not connected with Client::Connect. When calling Client::Connect, the application ID is set automatically.

◆ SetAuthorizeDeviceScreenClosedCallback()

void discordpp::Client::SetAuthorizeDeviceScreenClosedCallback ( discordpp::Client::AuthorizeDeviceScreenClosedCallback cb)

Sets a callback function to be invoked when the device authorization screen is closed.

◆ SetAutomaticGainControl()

void discordpp::Client::SetAutomaticGainControl ( bool on)

When enabled, automatically adjusts the microphone volume to keep it clear and consistent.

Defaults to on.

Generally this shouldn't need to be used unless you are building a voice settings UI for the user to control, similar to Discord's voice settings.

◆ SetDeviceChangeCallback()

void discordpp::Client::SetDeviceChangeCallback ( discordpp::Client::DeviceChangeCallback callback)

Sets a callback function to be invoked when Discord detects a change in the available audio devices.

◆ SetEchoCancellation()

void discordpp::Client::SetEchoCancellation ( bool on)

Enables or disables the basic echo cancellation provided by the WebRTC library.

Defaults to on.

Generally this shouldn't need to be used unless you are building a voice settings UI for the user to control, similar to Discord's voice settings.

◆ SetGameWindowPid()

void discordpp::Client::SetGameWindowPid ( int32_t pid)

When users are linking their account with Discord, which involves an OAuth2 flow, the SDK can streamline it by using Discord's overlay so the interaction happens entirely in-game. If your game's main window is not the same process as the one running the integration you may need to set the window PID using this method. It defaults to the current pid.

◆ SetInputDevice()

void discordpp::Client::SetInputDevice ( std::string deviceId,
discordpp::Client::SetInputDeviceCallback cb )

Asynchronously changes the audio input device in use by the client to the specified device. You can find the list of device IDs that can be passed in with the Client::GetInputDevices function.

◆ SetInputVolume()

void discordpp::Client::SetInputVolume ( float inputVolume)

Sets the microphone volume for the current user.

Input volume is specified as a percentage in the range [0, 100] which represents the perceptual loudness.

◆ SetLobbyCreatedCallback()

void discordpp::Client::SetLobbyCreatedCallback ( discordpp::Client::LobbyCreatedCallback cb)

Sets a callback to be invoked when a lobby "becomes available" to the client.

A lobby can become available in a few situations:

  • A new lobby is created and the current user is a member of it
  • The current user is added to an existing lobby
  • A lobby recovers after a backend crash and is available once again

This means that the LobbyCreated callback can be invoked more than once in a single session! Generally though it should never be invoked twice in a row. For example if a lobby crashes or a user is removed from the lobby, you should expect to have the LobbyDeleted callback invoked first.

◆ SetLobbyDeletedCallback()

void discordpp::Client::SetLobbyDeletedCallback ( discordpp::Client::LobbyDeletedCallback cb)

Sets a callback to be invoked when a lobby is no longer available.

This callback can be invoked in a number of situations:

  • A lobby the user is a member of is deleted
  • The current user is removed from a lobby
  • There is a backend crash that causes the lobby to be unavailable for all users

This means that this callback might be invoked even though the lobby still exists for other users!

◆ SetLobbyMemberAddedCallback()

void discordpp::Client::SetLobbyMemberAddedCallback ( discordpp::Client::LobbyMemberAddedCallback cb)

Sets a callback function to be invoked whenever a user is added to a lobby.

This callback will not be invoked when the current user is added to a lobby, instead the LobbyCreated callback will be invoked. Additionally, the SDK separates membership in a lobby from whether a user is connected to a lobby. So a user being added does not necessarily mean they are online and in the lobby at that moment, just that they have permission to connect to that lobby.

◆ SetLobbyMemberRemovedCallback()

void discordpp::Client::SetLobbyMemberRemovedCallback ( discordpp::Client::LobbyMemberRemovedCallback cb)

Sets a callback function to be invoked whenever a member of a lobby is removed and can no longer connect to it.

This callback will not be invoked when the current user is removed from a lobby, instead LobbyDeleted callback will be invoked. Additionally this is not invoked when a user simply exits the game. That would cause the LobbyMemberUpdatedCallback to be invoked, and the LobbyMemberHandle object will indicate they are not connected now.

◆ SetLobbyMemberUpdatedCallback()

void discordpp::Client::SetLobbyMemberUpdatedCallback ( discordpp::Client::LobbyMemberUpdatedCallback cb)

Sets a callback function to be invoked whenever a member of a lobby is changed.

This is invoked when:

  • The user connects or disconnects
  • The metadata of the member is changed

◆ SetLobbyUpdatedCallback()

void discordpp::Client::SetLobbyUpdatedCallback ( discordpp::Client::LobbyUpdatedCallback cb)

Sets a callback to be invoked when a lobby is edited, for example if the lobby's metadata is changed.

◆ SetLogDir()

bool discordpp::Client::SetLogDir ( std::string const & path,
discordpp::LoggingSeverity minSeverity )

Causes logs generated by the SDK to be written to disk in the specified directory.

This function explicitly excludes most logs for voice and webrtc activity since those are generally much noisier and you may want to pick a different log level for those. So it will instead include logs for things such as lobbies, relationships, presence, and authentication. An empty path defaults to logging alongside the client library. A minSeverity = LoggingSeverity::None disables logging to a file (also the current default). The logs will be placed into a file called "discord.log" in the specified directory. Overwrites any existing discord.log file.

We strongly recommend invoking this function immediately after constructing the Client object.

Returns true if the log file was successfully opened, false otherwise.

◆ SetMessageCreatedCallback()

void discordpp::Client::SetMessageCreatedCallback ( discordpp::Client::MessageCreatedCallback cb)

Sets a callback to be invoked whenever a new message is received in either a lobby or a DM.

From the messageId you can fetch the MessageHandle and then the ChannelHandle to determine the location the message was sent as well.

If the user has the Discord desktop application open on the same machine as the game, then they will hear notifications from the Discord application, even though they are able to see those messages in game. So to avoid double-notifying users, you should call Client::SetShowingChat whenever the chat is shown or hidden to suppress those duplicate notifications.

◆ SetMessageDeletedCallback()

void discordpp::Client::SetMessageDeletedCallback ( discordpp::Client::MessageDeletedCallback cb)

Sets a callback to be invoked whenever a message is deleted.

Some messages sent from in game, as well as all messages sent from a connected user's Discord client can be edited and deleted in the Discord client. So it is valuable to implement support for this callback so that if a user edits or deletes a message in the Discord client, it is reflected in game as well.

◆ SetMessageUpdatedCallback()

void discordpp::Client::SetMessageUpdatedCallback ( discordpp::Client::MessageUpdatedCallback cb)

Sets a callback to be invoked whenever a message is edited.

Some messages sent from in game, as well as all messages sent from a connected user's Discord client can be edited and deleted in the Discord client. So it is valuable to implement support for this callback so that if a user edits or deletes a message in the Discord client, it is reflected in game as well.

◆ SetNoAudioInputCallback()

void discordpp::Client::SetNoAudioInputCallback ( discordpp::Client::NoAudioInputCallback callback)

Callback function invoked when the above threshold is set and there is a change in whether audio is being detected.

◆ SetNoAudioInputThreshold()

void discordpp::Client::SetNoAudioInputThreshold ( float dBFSThreshold)

Threshold that can be set to indicate when no audio is being received by the user's mic.

An example of when this may be useful: When push to talk is being used and the user pushes their talk key, but something is configured wrong and no audio is being received, this threshold and callback can be used to detect that situation and notify the user. The threshold is specified in DBFS, or decibels relative to full scale, and the range is [-100.0, 100.0] It defaults to -100.0, so is disabled.

◆ SetNoiseSuppression()

void discordpp::Client::SetNoiseSuppression ( bool on)

Enables basic background noise suppression.

Defaults to on.

Generally this shouldn't need to be used unless you are building a voice settings UI for the user to control, similar to Discord's voice settings.

◆ SetOnlineStatus()

void discordpp::Client::SetOnlineStatus ( discordpp::StatusType status,
discordpp::Client::UpdateStatusCallback callback )

Sets whether a user is online/invisible/idle/dnd on Discord.

◆ SetOpusHardwareCoding()

void discordpp::Client::SetOpusHardwareCoding ( bool encode,
bool decode )

Enables or disables hardware encoding and decoding for audio, if it is available.

Defaults to on.

This must be called immediately after constructing the Client. If called too late an error will be logged and the setting will not take effect.

◆ SetOutputDevice()

void discordpp::Client::SetOutputDevice ( std::string deviceId,
discordpp::Client::SetOutputDeviceCallback cb )

Asynchronously changes the audio output device in use by the client to the specified device. You can find the list of device IDs that can be passed in with the Client::GetOutputDevices function.

◆ SetOutputVolume()

void discordpp::Client::SetOutputVolume ( float outputVolume)

Sets the speaker volume for the current user.

Output volume specified as a percentage in the range [0, 200] which represents the perceptual loudness.

◆ SetRelationshipCreatedCallback()

void discordpp::Client::SetRelationshipCreatedCallback ( discordpp::Client::RelationshipCreatedCallback cb)

Sets a callback to be invoked whenever a relationship for this user is established or changes type.

This can be invoked when a user sends or accepts a friend invite or blocks a user for example.

◆ SetRelationshipDeletedCallback()

void discordpp::Client::SetRelationshipDeletedCallback ( discordpp::Client::RelationshipDeletedCallback cb)

Sets a callback to be invoked whenever a relationship for this user is removed, such as when the user rejects a friend request or removes a friend.

When a relationship is removed, Client::GetRelationshipHandle will return a relationship with the type set to RelationshipType::None.

◆ SetSelfDeafAll()

void discordpp::Client::SetSelfDeafAll ( bool deaf)

Mutes all audio from the currently active call for the current user in all calls. They will not be able to hear any other participants, and no other participants will be able to hear the current user either. Note: This overrides the per-call setting.

◆ SetSelfMuteAll()

void discordpp::Client::SetSelfMuteAll ( bool mute)

Mutes the current user's microphone so that no other participant in their active calls can hear them in all calls. Note: This overrides the per-call setting.

◆ SetShowingChat()

void discordpp::Client::SetShowingChat ( bool showingChat)

Sets whether chat messages are currently being shown in the game.

If the user has the Discord desktop application open on the same machine as the game, then they will hear notifications from the Discord application, even though they are able to see those messages in game. So to avoid double-notifying users, you can call this function whenever the chat is shown or hidden to suppress those duplicate notifications.

Keep in mind, if the game stops showing chat for a period of time, or the game loses focus because the user switches to a different app, it is important to call this function again so that the user's notifications get re-enabled in Discord during this time.

◆ SetSpeakerMode()

bool discordpp::Client::SetSpeakerMode ( bool speakerMode)

On mobile devices, enable speakerphone mode.

◆ SetStatusChangedCallback()

void discordpp::Client::SetStatusChangedCallback ( discordpp::Client::OnStatusChanged cb)

Sets a callback function to be invoked whenever the SDKs status changes.

◆ SetThreadPriority()

void discordpp::Client::SetThreadPriority ( discordpp::Client::Thread thread,
int32_t priority )

Allows setting the priority of various SDK threads.

The threads that can be controlled are:

  • Client: This is the main thread for the SDK where most of the data processing happens
  • Network: This is the thread that receives voice data from lobby calls
  • Voice: This is the thread that the voice engine runs on and processes all audio data

◆ SetTokenExpirationCallback()

void discordpp::Client::SetTokenExpirationCallback ( discordpp::Client::TokenExpirationCallback callback)

Get a notification when the current token is about to expire or expired.

This callback is invoked when the SDK detects that the last token passed to Client::UpdateToken is nearing expiration or has expired. This is a signal to the developer to refresh the token. The callback is invoked once per token, and will not be invoked again until a new token is passed to Client::UpdateToken.

If the token is refreshed before the expiration callback is invoked, call Client::UpdateToken to pass in the new token and reconfigure the token expiration.

If your client is disconnected (the token was expired when connecting or was revoked while connected), the expiration callback will not be invoked.

◆ SetUserUpdatedCallback()

void discordpp::Client::SetUserUpdatedCallback ( discordpp::Client::UserUpdatedCallback cb)

The UserUpdatedCallback is invoked whenever any user the current session knows about changes, not just if the current user changes. For example if one of your Discord friends changes their name or avatar the UserUpdatedCallback will be invoked. It is also invoked when users come online, go offline, or start playing your game.

◆ SetVoiceLogDir()

void discordpp::Client::SetVoiceLogDir ( std::string const & path,
discordpp::LoggingSeverity minSeverity )

Causes logs generated by the voice subsystem of the SDK to be written to disk in the specified directory.

These logs will be in a file like discord-webrtc_0, and if they grow to big will be rotated and the number incremented. If the log files already exist the old ones will be renamed to discord-last-webrtc_0.

An empty path defaults to logging alongside the client library. A minSeverity = LoggingSeverity::None disables logging to a file (also the current default).

WARNING: This function MUST be invoked immediately after constructing the Client object! It will print out a warning if invoked too late.

◆ SetVoiceParticipantChangedCallback()

void discordpp::Client::SetVoiceParticipantChangedCallback ( discordpp::Client::VoiceParticipantChangedCallback cb)

Callback invoked whenever a user in a lobby joins or leaves a voice call.

The main use case for this is to enable displaying which users are in voice in a lobby even if the current user is not in voice yet, and thus does not have a Call object to bind to.

◆ ShowAudioRoutePicker()

bool discordpp::Client::ShowAudioRoutePicker ( )

On iOS devices, show the system audio route picker.

◆ StartCall()

discordpp::Call discordpp::Client::StartCall ( uint64_t channelId)

Starts or joins a call in the lobby specified by channelId (For a lobby, simply pass in the lobbyId).

On iOS, your application is responsible for enabling the appropriate background audio mode in your Info.plist. VoiceBuildPostProcessor in the sample demonstrates how to do this automatically in your Unity build process.

On macOS, you should set the NSMicrophoneUsageDescription key in your Info.plist.

Returns null if the user is already in the given voice channel.

◆ StartCallWithAudioCallbacks()

discordpp::Call discordpp::Client::StartCallWithAudioCallbacks ( uint64_t lobbyId,
discordpp::Client::UserAudioReceivedCallback receivedCb,
discordpp::Client::UserAudioCapturedCallback capturedCb )

Starts or joins a call in the specified lobby.

The audio received callback is invoked whenever incoming audio is received in a call. If the developer sets outShouldMute to true during the callback, the audio data will be muted after the callback is invoked, which is useful if the developer is utilizing the incoming audio and playing it through their own audio engine or playback. The audio samples in data can be modified in-place for simple DSP effects.

The audio captured callback is invoked whenever local audio is captured before it is processed and transmitted which may be useful for voice moderation, etc.

On iOS, your application is responsible for enabling the appropriate background audio mode in your Info.plist. VoiceBuildPostProcessor in the sample demonstrates how to do this automatically in your Unity build process.

On macOS, you should set the NSMicrophoneUsageDescription key in your Info.plist.

Returns null if the user is already in the given voice channel.

◆ StatusToString()

static std::string discordpp::Client::StatusToString ( discordpp::Client::Status type)
static

Converts the Status enum to a string.

◆ ThreadToString()

static std::string discordpp::Client::ThreadToString ( discordpp::Client::Thread type)
static

Converts the Thread enum to a string.

◆ UnblockUser()

void discordpp::Client::UnblockUser ( uint64_t userId,
discordpp::Client::UpdateRelationshipCallback cb )

Unblocks the target user. Does not restore any old relationship between the users though.

Fails if the target user is not currently blocked.

◆ UnlinkChannelFromLobby()

void discordpp::Client::UnlinkChannelFromLobby ( uint64_t lobbyId,
discordpp::Client::LinkOrUnlinkChannelCallback callback )

Removes any existing channel link from the specified lobby.

See the docs on LobbyHandle for more information. A lobby can be unlinked by any user with the LobbyMemberFlags::CanLinkLobby flag, they do not need to have any permissions on the Discord channel in order to sever the in-game link.

◆ UpdateProvisionalAccountDisplayName()

void discordpp::Client::UpdateProvisionalAccountDisplayName ( std::string const & name,
discordpp::Client::UpdateProvisionalAccountDisplayNameCallback callback )

Updates the display name of a provisional account to the specified name.

This should generally be invoked whenever the SDK starts and whenever a provisional account changes their name, since the auto-generated name for provisional accounts is just a random string.

◆ UpdateRichPresence()

void discordpp::Client::UpdateRichPresence ( discordpp::Activity activity,
discordpp::Client::UpdateRichPresenceCallback cb )

Updates the rich presence for the current user.

You should use rich presence so that other users on Discord know this user is playing a game and you can include some hints of what they are playing such as a character name or map name. Rich presence also enables Discord game invites to work too!

Note: On Desktop, rich presence can be set before calling Client::Connect, but it will be cleared if the Client connects. When Client is not connected, this sets the rich presence in the current user's Discord client when available.

See the docs on the Activity struct for more details.

Note: The Activity object here is a partial object, fields such as name, and applicationId cannot be set and will be overwritten by the SDK. See https://discord.com/developers/docs/rich-presence/using-with-the-game-sdk#partial-activity-struct for more information.

◆ UpdateToken()

void discordpp::Client::UpdateToken ( discordpp::AuthorizationTokenType tokenType,
std::string token,
discordpp::Client::UpdateTokenCallback callback )

Asynchronously sets a new auth token for this client to use.

If your client is already connected, this function may trigger a reconnect. If your client is not connected, this function will only update the auth token, and so you must invoke Client::Connect as well. You should wait for the given callback function to be invoked though so that the next Client::Connect attempt uses the updated token.

Member Data Documentation

◆ nullobj

const Client discordpp::Client::nullobj
static

Uninitialized instance of Client.