Skip to content

Commit 6915904

Browse files
Anime-pdfMishura4
andauthored
feat: server tags support (#1477)
Co-authored-by: Miuna <[email protected]>
1 parent 6fe9405 commit 6915904

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

include/dpp/user.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ class DPP_EXPORT user : public managed, public json_interface<user> {
199199
*/
200200
utility::iconhash avatar_decoration;
201201

202+
/**
203+
* @brief Primary guild object (server tag)
204+
*/
205+
utility::primaryguild primary_guild;
206+
202207
/**
203208
* @brief Flags built from a bitmask of values in dpp::user_flags.
204209
*/

include/dpp/utility.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,33 @@ struct DPP_EXPORT iconhash {
323323
std::string to_string() const;
324324
};
325325

326+
/**
327+
* @brief User's primary guild (server tag)
328+
*/
329+
struct DPP_EXPORT primaryguild {
330+
/**
331+
* @brief The id of the user's primary guild
332+
*
333+
* @see guild
334+
*/
335+
snowflake id;
336+
337+
/**
338+
* @brief Whether the user is displaying the primary guild's server tag
339+
*/
340+
bool enabled;
341+
342+
/**
343+
* @brief The text of the user's server tag. Limited to 4 characters
344+
*/
345+
std::string tag;
346+
347+
/**
348+
* @brief The server tag badge
349+
*/
350+
iconhash badge;
351+
};
352+
326353
/**
327354
* @brief Image to be received or sent to API calls.
328355
*

src/dpp/user.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,14 @@ void from_json(const nlohmann::json& j, user& u) {
304304
u.flags |= flag.second;
305305
}
306306
}
307+
308+
if (j.contains("primary_guild") && !j.at("primary_guild").is_null()) {
309+
const auto *pg = &j["primary_guild"];
310+
u.primary_guild.id = snowflake_not_null(pg, "identity_guild_id");
311+
u.primary_guild.enabled = bool_not_null(pg, "identity_enabled");
312+
u.primary_guild.tag = string_not_null(pg, "tag");
313+
u.primary_guild.badge = string_not_null(pg, "badge");
314+
}
307315
}
308316

309317
}

0 commit comments

Comments
 (0)