Discord Social SDK
|
A UserHandle represents a single user on Discord that the SDK knows about and contains basic account information for them such as id, name, and avatar, as well as their "status" information which includes both whether they are online/offline/etc as well as whether they are playing this game.
Handle objects in the SDK hold a reference both to the underlying data, and to the SDK instance. Changes to the underlying data will generally be available on existing handles objects without having to re-create them. If the SDK instance is destroyed, but you still have a reference to a handle object, note that it will return the default value for all method calls (ie an empty string for methods that return a string).
Public Member Functions | |
UserHandle (UserHandle &&other) noexcept | |
Move constructor for UserHandle. | |
UserHandle & | operator= (UserHandle &&other) noexcept |
Move assignment operator for UserHandle. | |
operator bool () const | |
Returns true if the instance contains a valid object. | |
UserHandle (const UserHandle &arg0) | |
Copy constructor for UserHandle. | |
UserHandle & | operator= (const UserHandle &arg0) |
Copy assignment operator for UserHandle. | |
std::optional< std::string > | Avatar () const |
Returns the hash of the user's Discord profile avatar, if one is set. | |
std::string | AvatarUrl (discordpp::UserHandle::AvatarType animatedType, discordpp::UserHandle::AvatarType staticType) const |
Returns a CDN url to the user's Discord profile avatar. | |
std::string | DisplayName () const |
Returns the user's preferred name, if one is set, otherwise returns their unique username. | |
std::optional< discordpp::Activity > | GameActivity () const |
Returns the user's rich presence activity that is associated with the current game, if one is set. | |
std::optional< std::string > | GlobalName () const |
Returns the preferred display name of this user, if one is set. | |
uint64_t | Id () const |
Returns the ID of this user. | |
bool | IsProvisional () const |
Returns true if this user is a provisional account. | |
discordpp::RelationshipHandle | Relationship () const |
Returns a reference to the RelationshipHandle between the currently authenticated user and this user, if any. | |
discordpp::StatusType | Status () const |
Returns the user's online/offline/idle status. | |
std::string | Username () const |
Returns the globally unique username of this user. | |
Public Types | |
enum class | AvatarType { Gif = 0 , Webp = 1 , Png = 2 , Jpeg = 3 } |
The desired type of avatar url to generate for a User. More... | |
Static Public Member Functions | |
static std::string | AvatarTypeToString (discordpp::UserHandle::AvatarType type) |
Converts the AvatarType enum to a string. | |
Static Public Attributes | |
static const UserHandle | nullobj |
Uninitialized instance of UserHandle. | |
|
strong |
|
noexcept |
Move constructor for UserHandle.
discordpp::UserHandle::UserHandle | ( | const UserHandle & | arg0 | ) |
Copy constructor for UserHandle.
std::optional< std::string > discordpp::UserHandle::Avatar | ( | ) | const |
Returns the hash of the user's Discord profile avatar, if one is set.
|
static |
Converts the AvatarType enum to a string.
std::string discordpp::UserHandle::AvatarUrl | ( | discordpp::UserHandle::AvatarType | animatedType, |
discordpp::UserHandle::AvatarType | staticType ) const |
Returns a CDN url to the user's Discord profile avatar.
If the user does not have an avatar set, a url to one of Discord's default avatars is returned instead.
std::string discordpp::UserHandle::DisplayName | ( | ) | const |
Returns the user's preferred name, if one is set, otherwise returns their unique username.
std::optional< discordpp::Activity > discordpp::UserHandle::GameActivity | ( | ) | const |
Returns the user's rich presence activity that is associated with the current game, if one is set.
On Discord, users can have multiple rich presence activities at once, but the SDK will only expose the activity that is associated with your game. You can use this to know about the party the user is in, if any, and what the user is doing in the game.
For more information see the Activity class and check out https://discord.com/developers/docs/rich-presence/overview
std::optional< std::string > discordpp::UserHandle::GlobalName | ( | ) | const |
Returns the preferred display name of this user, if one is set.
Discord's public API refers to this as a "global name" instead of "display name".
Discord users can set their preferred name to almost any string.
For more information about usernames on Discord, see: https://discord.com/developers/docs/resources/user
uint64_t discordpp::UserHandle::Id | ( | ) | const |
Returns the ID of this user.
If this returns 0 then the UserHandle is no longer valid.
bool discordpp::UserHandle::IsProvisional | ( | ) | const |
Returns true if this user is a provisional account.
|
inline |
Returns true if the instance contains a valid object.
UserHandle & discordpp::UserHandle::operator= | ( | const UserHandle & | arg0 | ) |
Copy assignment operator for UserHandle.
|
noexcept |
Move assignment operator for UserHandle.
discordpp::RelationshipHandle discordpp::UserHandle::Relationship | ( | ) | const |
Returns a reference to the RelationshipHandle between the currently authenticated user and this user, if any.
discordpp::StatusType discordpp::UserHandle::Status | ( | ) | const |
Returns the user's online/offline/idle status.
std::string discordpp::UserHandle::Username | ( | ) | const |
Returns the globally unique username of this user.
For provisional accounts this is an auto-generated string.
For more information about usernames on Discord, see: https://discord.com/developers/docs/resources/user
|
static |
Uninitialized instance of UserHandle.