summaryrefslogtreecommitdiff
path: root/discord/user.cpp
blob: 78d309b5c7f3d1a6e4baf9fd59e7cffc497805a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "user.hpp"
#include "../abaddon.hpp"

bool User::HasAvatar() const {
    return Avatar.size() > 0;
}

std::string User::GetAvatarURL(std::string ext, std::string size) const {
    return "https://cdn.discordapp.com/avatars/" + std::to_string(ID) + "/" + Avatar + "." + ext + "?size=" + size;
}

Snowflake User::GetHoistedRole(Snowflake guild_id, bool with_color) const {
    return Abaddon::Get().GetDiscordClient().GetMemberHoistedRole(guild_id, ID, with_color);
}

void from_json(const nlohmann::json &j, User &m) {
    JS_D("id", m.ID);
    JS_D("username", m.Username);
    JS_D("discriminator", m.Discriminator);
    JS_N("avatar", m.Avatar);
    JS_O("bot", m.IsBot);
    JS_O("system", m.IsSystem);
    JS_O("mfa_enabled", m.IsMFAEnabled);
    JS_O("locale", m.Locale);
    JS_O("verified", m.IsVerified);
    JS_O("email", m.Email);
    JS_O("flags", m.Flags);
    JS_ON("premium_type", m.PremiumType);
    JS_O("public_flags", m.PublicFlags);
    JS_O("desktop", m.IsDesktop);
    JS_O("mobile", m.IsMobile);
    JS_ON("nsfw_allowed", m.IsNSFWAllowed);
    JS_ON("phone", m.Phone);
}

void User::update_from_json(const nlohmann::json &j, User &m) {
    JS_RD("username", m.Username);
    JS_RD("discriminator", m.Discriminator);
    JS_RD("avatar", m.Avatar);
    JS_RD("bot", m.IsBot);
    JS_RD("system", m.IsSystem);
    JS_RD("mfa_enabled", m.IsMFAEnabled);
    JS_RD("locale", m.Locale);
    JS_RD("verified", m.IsVerified);
    JS_RD("email", m.Email);
    JS_RD("flags", m.Flags);
    JS_RD("premium_type", m.PremiumType);
    JS_RD("public_flags", m.PublicFlags);
    JS_RD("desktop", m.IsDesktop);
    JS_RD("mobile", m.IsMobile);
    JS_RD("nsfw_allowed", m.IsNSFWAllowed);
    JS_RD("phone", m.Phone);
}