Skip to content

Commit

Permalink
fix: make things compile properly due to making nickname, roles and f…
Browse files Browse the repository at this point in the history
…lags private
  • Loading branch information
braindigitalis committed Oct 2, 2023
1 parent dbb7b1f commit 658b587
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 3 additions & 1 deletion include/dpp/guild.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ class DPP_EXPORT guild_member {
std::vector<snowflake> roles;
/** A set of flags built from the bitmask defined by dpp::guild_member_flags */
uint16_t flags;

friend void from_json(const nlohmann::json& j, guild_member& gm);
public:
/** Guild id */
snowflake guild_id;
Expand Down Expand Up @@ -337,7 +339,7 @@ class DPP_EXPORT guild_member {
*
* @return std::vector<dpp::snowflake> roles
*/
std::vector<dpp::snowflake> get_roles();
std::vector<dpp::snowflake> get_roles() const;

/**
* @brief Find the dpp::user object for this member. This is an alias for dpp::find_user
Expand Down
8 changes: 4 additions & 4 deletions src/dpp/guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ std::string guild_member::get_nickname() {
return nickname;
}

std::vector<dpp::snowflake> guild_member::get_roles() {
std::vector<dpp::snowflake> guild_member::get_roles() const {
return roles;
}

Expand Down Expand Up @@ -752,7 +752,7 @@ permission guild::base_permissions(const guild_member &member) const {

permission permissions = everyone->permissions;

for (auto& rid : member.roles) {
for (auto& rid : member.get_roles()) {
role* r = dpp::find_role(rid);
if (r) {
permissions |= r->permissions;
Expand Down Expand Up @@ -799,7 +799,7 @@ permission guild::permission_overwrites(const uint64_t base_permissions, const u
uint64_t allow = 0;
uint64_t deny = 0;

for (auto& rid : gm.roles) {
for (auto& rid : gm.get_roles()) {

/* Skip \@everyone role to not break the hierarchy. It's calculated above */
if (rid == this->id) {
Expand Down Expand Up @@ -855,7 +855,7 @@ permission guild::permission_overwrites(const guild_member &member, const channe
uint64_t allow = 0;
uint64_t deny = 0;

for (auto& rid : member.roles) {
for (auto& rid : member.get_roles()) {

/* Skip \@everyone role to not break the hierarchy. It's calculated above */
if (rid == this->id) {
Expand Down
9 changes: 5 additions & 4 deletions src/dpp/role.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,9 @@ members_container role::get_members() const {
}
for (auto & m : g->members) {
/* Iterate all members and use std::find on their role list to see who has this role */
auto i = std::find(m.second.roles.begin(), m.second.roles.end(), this->id);
if (i != m.second.roles.end()) {
auto r = m.second.get_roles();
auto i = std::find(r.begin(), r.end(), this->id);
if (i != r.end()) {
gm[m.second.user_id] = m.second;
}
}
Expand All @@ -425,8 +426,8 @@ members_container role::get_members() const {
std::string role::get_icon_url(uint16_t size, const image_type format) const {
if (!this->icon.to_string().empty() && this->id) {
return utility::cdn_endpoint_url({ i_jpg, i_png, i_webp },
"role-icons/" + std::to_string(this->id) + "/" + this->icon.to_string(),
format, size);
"role-icons/" + std::to_string(this->id) + "/" + this->icon.to_string(),
format, size);
} else {
return std::string();
}
Expand Down
2 changes: 1 addition & 1 deletion src/unittest/coro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ void event_handler_test(dpp::cluster *bot) {
if (!pair.first.has_value()) {
co_return {};
}
const std::string& member_nick = pair.second.has_value() ? pair.second->nickname : "";
const std::string& member_nick = pair.second.has_value() ? pair.second->get_nickname() : "";
const std::string& user_nick = pair.first->username;
result = co_await bot->co_message_edit(msg.set_content("coro " + (member_nick.empty() ? user_nick : member_nick) + " " + std::to_string(i)));
co_return result.is_error() ? dpp::snowflake{} : std::get<dpp::message>(result.value).id;
Expand Down

0 comments on commit 658b587

Please sign in to comment.