Skip to content

Commit

Permalink
breaking: add get_nickname(), get_roles() and make nickname, roles an…
Browse files Browse the repository at this point in the history
…d flags members private
  • Loading branch information
braindigitalis committed Oct 2, 2023
1 parent 3234946 commit dbb7b1f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
21 changes: 18 additions & 3 deletions include/dpp/guild.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<snowflake> 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 */
Expand All @@ -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();
Expand Down Expand Up @@ -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<dpp::snowflake> roles
*/
std::vector<dpp::snowflake> 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
Expand Down
13 changes: 11 additions & 2 deletions src/dpp/guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -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<dpp::snowflake> guild_member::get_roles() {
return roles;
}


guild_member& guild_member::set_roles(const std::vector<dpp::snowflake> &role_ids) {
roles = role_ids;
flags |= gm_roles_action;
Expand Down

0 comments on commit dbb7b1f

Please sign in to comment.