summaryrefslogtreecommitdiff
path: root/discord/user.hpp
blob: cf6c2faa847956678f7ffe24142ef59e3962d617 (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
#pragma once
#include "snowflake.hpp"
#include "json.hpp"
#include <string>

struct User {
    Snowflake ID;
    std::string Username;
    std::string Discriminator;
    std::string Avatar; // null
    std::optional<bool> IsBot;
    std::optional<bool> IsSystem;
    std::optional<bool> IsMFAEnabled;
    std::optional<std::string> Locale;
    std::optional<bool> IsVerified;
    std::optional<std::string> Email; // null
    std::optional<int> Flags;
    std::optional<int> PremiumType; // null
    std::optional<int> PublicFlags;

    // undocumented (opt)
    std::optional<bool> IsDesktop;
    std::optional<bool> IsMobile;
    std::optional<bool> IsNSFWAllowed; // null
    std::optional<std::string> Phone;  // null?

    friend void from_json(const nlohmann::json &j, User &m);
    friend void to_json(nlohmann::json &j, const User &m);
    static void update_from_json(const nlohmann::json &j, User &m);

    bool HasAvatar() const;
    bool HasAnimatedAvatar() const;
    std::string GetAvatarURL(std::string ext = "png", std::string size = "32") const;
    Snowflake GetHoistedRole(Snowflake guild_id, bool with_color = false) const;
    std::string GetMention() const;
};