Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking, fix: guild_member state tracking #909

Merged
merged 13 commits into from
Oct 2, 2023
18 changes: 6 additions & 12 deletions src/dpp/guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@
}

guild_member& guild_member::remove_role(dpp::snowflake role_id) {
roles.erase(std::remove_if(roles.begin(), roles.end(), [&role_id](dpp::snowflake role) {
return role == role_id;
}), roles.end());
std::remove(roles.begin(), roles.end(), role_id);

Check warning on line 126 in src/dpp/guild.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/dpp/guild.cpp#L126

Return value of std::remove() ignored. Elements remain in container.
Mishura4 marked this conversation as resolved.
Show resolved Hide resolved
flags |= gm_roles_action;
return *this;
}
Expand Down Expand Up @@ -219,8 +217,8 @@
std::string guild_member::get_avatar_url(uint16_t size, const image_type format, bool prefer_animated) const {
if (this->guild_id && this->user_id && !this->avatar.to_string().empty()) {
return utility::cdn_endpoint_url_hash({ i_jpg, i_png, i_webp, i_gif },
"guilds/" + std::to_string(this->guild_id) + "/" + std::to_string(this->user_id), this->avatar.to_string(),
format, size, prefer_animated, has_animated_guild_avatar());
"guilds/" + std::to_string(this->guild_id) + "/" + std::to_string(this->user_id), this->avatar.to_string(),
format, size, prefer_animated, has_animated_guild_avatar());
} else {
return std::string();
}
Expand Down Expand Up @@ -250,13 +248,9 @@
}

if (gm_roles_action) {
if (!this->roles.empty()) {
j["roles"] = {};
for (const auto & role : this->roles) {
j["roles"].push_back(std::to_string(role));
}
} else {
j["roles"] = {};
j["roles"] = {};
Mishura4 marked this conversation as resolved.
Show resolved Hide resolved
for (const auto & role : this->roles) {
j["roles"].push_back(std::to_string(role));
}
}

Expand Down
Loading