Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/dpp/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ class DPP_EXPORT user : public managed, public json_interface<user> {
*/
utility::iconhash avatar_decoration;

/**
* @brief Primary guild object (server tag)
*/
utility::primaryguild primary_guild;

/**
* @brief Flags built from a bitmask of values in dpp::user_flags.
*/
Expand Down
27 changes: 27 additions & 0 deletions include/dpp/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,33 @@ struct DPP_EXPORT iconhash {
std::string to_string() const;
};

/**
* @brief User's primary guild (server tag)
*/
struct DPP_EXPORT primaryguild {
/**
* @brief The id of the user's primary guild
*
* @see guild
*/
snowflake id;

/**
* @brief Whether the user is displaying the primary guild's server tag
*/
bool enabled;

/**
* @brief The text of the user's server tag. Limited to 4 characters
*/
std::string tag;

/**
* @brief The server tag badge
*/
iconhash badge;
};

/**
* @brief Image to be received or sent to API calls.
*
Expand Down
8 changes: 8 additions & 0 deletions src/dpp/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,14 @@ void from_json(const nlohmann::json& j, user& u) {
u.flags |= flag.second;
}
}

if (j.contains("primary_guild") && !j.at("primary_guild").is_null()) {
const auto *pg = &j["primary_guild"];
u.primary_guild.id = snowflake_not_null(pg, "identity_guild_id");
u.primary_guild.enabled = bool_not_null(pg, "identity_enabled");
u.primary_guild.tag = string_not_null(pg, "tag");
u.primary_guild.badge = string_not_null(pg, "badge");
}
}

}
Loading