aegis.cpp
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
emoji.hpp
1 //
2 // emoji.hpp
3 // *********
4 //
5 // Copyright (c) 2019 Sharon W (sharon at aegis dot gg)
6 //
7 // Distributed under the MIT License. (See accompanying file LICENSE)
8 //
9 
10 #pragma once
11 
12 #include "aegis/config.hpp"
13 #include "aegis/snowflake.hpp"
14 #include <nlohmann/json.hpp>
15 
16 namespace aegis
17 {
18 
19 namespace gateway
20 {
21 
22 namespace objects
23 {
24 
26 struct emoji
27 {
29  std::string name;
30  std::vector<snowflake> roles;
32  bool require_colons = false;
33  bool managed = false;
34  bool animated = false;
35 };
36 
38 inline void from_json(const nlohmann::json& j, emoji& m)
39 {
40  m.id = j["id"];
41  if (j.count("name") && !j["name"].is_null())
42  m.name = j["name"].get<std::string>();
43  if (j.count("user") && !j["user"].is_null())
44  m.user = j["user"]["id"];
45  if (j.count("require_colons") && !j["require_colons"].is_null())
46  m.require_colons = j["require_colons"];
47  if (j.count("managed") && !j["managed"].is_null())
48  m.managed = j["managed"];
49  if (j.count("animated") && !j["animated"].is_null())
50  m.animated = j["animated"];
51  if (j.count("roles") && !j["roles"].is_null())
52  for (const auto & i : j["roles"])
53  m.roles.push_back(i);
54 }
55 
56 inline void to_json(nlohmann::json& j, const emoji& m)
57 {
58  j["id"] = std::to_string(m.id);
59  j["name"] = m.name;
60  j["user"] = m.user;
61  j["require_colons"] = m.require_colons;
62  j["managed"] = m.managed;
63  j["animated"] = m.animated;
64  for (const auto & i : m.roles)
65  j["roles"].push_back(i);
66 }
68 
69 }
70 
71 }
72 
73 }
Stores creation time and extra data specific to Discord for entities.
Definition: snowflake.hpp:21
snowflake user
Definition: emoji.hpp:31
std::vector< snowflake > roles
Definition: emoji.hpp:30
bool managed
Definition: emoji.hpp:33
std::string name
Definition: emoji.hpp:29
Discord Emoji Object.
Definition: emoji.hpp:26
bool animated
Definition: emoji.hpp:34
bool require_colons
Definition: emoji.hpp:32
snowflake id
Definition: emoji.hpp:28