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

struct EmojiData {
    Snowflake ID;     // null
    std::string Name; // null (in reactions)
    std::optional<std::vector<Snowflake>> Roles;
    std::optional<UserData> Creator; // only reliable to access ID
    std::optional<bool> NeedsColons;
    std::optional<bool> IsManaged;
    std::optional<bool> IsAnimated;
    std::optional<bool> IsAvailable;

    friend void from_json(const nlohmann::json &j, EmojiData &m);
    friend void to_json(nlohmann::json &j, const EmojiData &m);

    std::string GetURL(const char *ext = "png", const char *size = nullptr) const;
    static std::string URLFromID(const std::string &emoji_id, const char *ext = "png", const char *size = nullptr);
    static std::string URLFromID(Snowflake emoji_id, const char *ext = "png", const char *size = nullptr);
    static std::string URLFromID(const Glib::ustring &emoji_id, const char *ext = "png", const char *size = nullptr);
};