abaddon/discord/member.cpp
ouwou fd72d91cee handle merged_members in ready object
this way you dont have to load a channel to make the client aware of your permissions
2021-01-23 18:23:14 -05:00

37 lines
1.0 KiB
C++

#include "member.hpp"
#include "../abaddon.hpp"
void from_json(const nlohmann::json &j, GuildMember &m) {
JS_O("user", m.User);
JS_ON("nick", m.Nickname);
JS_D("roles", m.Roles);
JS_D("joined_at", m.JoinedAt);
JS_ON("premium_since", m.PremiumSince);
JS_D("deaf", m.IsDeafened);
JS_D("mute", m.IsMuted);
JS_O("user_id", m.UserID);
}
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;
}
void GuildMember::update_from_json(const nlohmann::json &j) {
JS_RD("roles", Roles);
JS_RD("user", User);
JS_RD("nick", Nickname);
JS_RD("joined_at", JoinedAt);
JS_RD("premium_since", PremiumSince);
}