From dbb7b1faa620b9cadc8455651740ea749bfade0c Mon Sep 17 00:00:00 2001 From: Craig Edwards Date: Mon, 2 Oct 2023 13:41:40 +0000 Subject: [PATCH] breaking: add get_nickname(), get_roles() and make nickname, roles and flags members private --- include/dpp/guild.h | 21 ++++++++++++++++++--- src/dpp/guild.cpp | 13 +++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/include/dpp/guild.h b/include/dpp/guild.h index 4877010db3..d5a92582f2 100644 --- a/include/dpp/guild.h +++ b/include/dpp/guild.h @@ -189,11 +189,14 @@ enum guild_member_flags : uint16_t { * This contains the user's nickname, guild roles, and any other guild-specific flags. */ class DPP_EXPORT guild_member { -public: +protected: /** Nickname, or empty string if they don't have a nickname on this guild */ std::string nickname; /** List of roles this user has on this guild */ std::vector roles; + /** A set of flags built from the bitmask defined by dpp::guild_member_flags */ + uint16_t flags; +public: /** Guild id */ snowflake guild_id; /** User id */ @@ -206,8 +209,6 @@ class DPP_EXPORT guild_member { time_t joined_at; /** Boosting since */ time_t premium_since; - /** A set of flags built from the bitmask defined by dpp::guild_member_flags */ - uint16_t flags; /** Default constructor */ guild_member(); @@ -324,6 +325,20 @@ class DPP_EXPORT guild_member { */ guild_member& set_nickname(const std::string& nick); + /** + * @brief Get the nickname + * + * @return std::string nickname + */ + std::string get_nickname(); + + /** + * @brief Get the roles + * + * @return std::vector roles + */ + std::vector get_roles(); + /** * @brief Find the dpp::user object for this member. This is an alias for dpp::find_user * @return dpp::user* Pointer to the user object. If not in cache, it returns nullptr diff --git a/src/dpp/guild.cpp b/src/dpp/guild.cpp index 33a16c7269..80cf237392 100644 --- a/src/dpp/guild.cpp +++ b/src/dpp/guild.cpp @@ -97,12 +97,12 @@ guild::guild() : guild_member::guild_member() : + flags(0), guild_id(0), user_id(0), communication_disabled_until(0), joined_at(0), - premium_since(0), - flags(0) + premium_since(0) { } @@ -130,6 +130,15 @@ guild_member& guild_member::remove_role(dpp::snowflake role_id) { return *this; } +std::string guild_member::get_nickname() { + return nickname; +} + +std::vector guild_member::get_roles() { + return roles; +} + + guild_member& guild_member::set_roles(const std::vector &role_ids) { roles = role_ids; flags |= gm_roles_action;