Discord Social SDK
|
A RelationshipHandle represents the relationship between the current user and a target user on Discord. Relationships include friends, blocked users, and friend invites.
The SDK supports two types of relationships:
If someone is a game friend they can later choose to "upgrade" to a full Discord friend. In this case, the user has two relationships at the same time, which is why there are two different type fields on RelationshipHandle. In this example, their RelationshipHandle::DiscordRelationshipType would be set to RelationshipType::PendingIncoming or RelationshipType::PendingOutgoing (based on whether they are receiving or sending the invite respectively), and their RelationshipHandle::GameRelationshipType would remain as RelationshipType::Friend.
When a user blocks another user, it is always stored on the RelationshipHandle::DiscordRelationshipType field, and will persist across games. It is not possible to block a user in only one game.
See the Friends documentation for more information.
Note: While the SDK allows you to manage a user's relationships, you should never take an action without their explicit consent. You should not automatically send or accept friend requests. Only invoke APIs to manage relationships in response to a user action such as clicking a "Send Friend Request" button.
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 | |
RelationshipHandle (RelationshipHandle &&other) noexcept | |
Move constructor for RelationshipHandle. | |
RelationshipHandle & | operator= (RelationshipHandle &&other) noexcept |
Move assignment operator for RelationshipHandle. | |
operator bool () const | |
Returns true if the instance contains a valid object. | |
RelationshipHandle (const RelationshipHandle &other) | |
Copy constructor for RelationshipHandle. | |
RelationshipHandle & | operator= (const RelationshipHandle &other) |
Copy assignment operator for RelationshipHandle. | |
discordpp::RelationshipType | DiscordRelationshipType () const |
Returns the type of the Discord relationship. | |
discordpp::RelationshipType | GameRelationshipType () const |
Returns the type of the Game relationship. | |
uint64_t | Id () const |
Returns the ID of the target user in this relationship. | |
std::optional< discordpp::UserHandle > | User () const |
Returns a handle to the target user in this relationship, if one is available. This would be the user with the same ID as the one returned by the Id() method. | |
Static Public Attributes | |
static const RelationshipHandle | nullobj |
Uninitialized instance of RelationshipHandle. | |
|
noexcept |
Move constructor for RelationshipHandle.
discordpp::RelationshipHandle::RelationshipHandle | ( | const RelationshipHandle & | other | ) |
Copy constructor for RelationshipHandle.
discordpp::RelationshipType discordpp::RelationshipHandle::DiscordRelationshipType | ( | ) | const |
Returns the type of the Discord relationship.
discordpp::RelationshipType discordpp::RelationshipHandle::GameRelationshipType | ( | ) | const |
Returns the type of the Game relationship.
uint64_t discordpp::RelationshipHandle::Id | ( | ) | const |
Returns the ID of the target user in this relationship.
|
inline |
Returns true if the instance contains a valid object.
RelationshipHandle & discordpp::RelationshipHandle::operator= | ( | const RelationshipHandle & | other | ) |
Copy assignment operator for RelationshipHandle.
|
noexcept |
Move assignment operator for RelationshipHandle.
std::optional< discordpp::UserHandle > discordpp::RelationshipHandle::User | ( | ) | const |
Returns a handle to the target user in this relationship, if one is available. This would be the user with the same ID as the one returned by the Id() method.
|
static |
Uninitialized instance of RelationshipHandle.