mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-13 20:18:50 +03:00
add role list to user menu
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user