add role list to user menu

This commit is contained in:
ouwou
2021-01-16 23:48:19 -05:00
parent 462f801af2
commit 3a25249a0d
4 changed files with 48 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
#include "member.hpp"
#include "../abaddon.hpp"
void from_json(const nlohmann::json &j, GuildMember &m) {
JS_O("user", m.User);
@@ -10,6 +11,21 @@ void from_json(const nlohmann::json &j, GuildMember &m) {
JS_D("mute", m.IsMuted);
}
std::vector<RoleData> GuildMember::GetSortedRoles() const {
std::vector<RoleData> roles;
for (const auto role_id : Roles) {
const auto role = Abaddon::Get().GetDiscordClient().GetRole(role_id);
if (!role.has_value()) continue;
roles.push_back(std::move(*role));
}
std::sort(roles.begin(), roles.end(), [](const RoleData &a, const RoleData &b) {
return a.Position > b.Position;
});
return roles;
}
GuildMember GuildMember::from_update_json(const nlohmann::json &j) {
GuildMember ret;
JS_D("roles", ret.Roles);