aegis.cpp
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
guild_member.hpp
1 //
2 // guild_member.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 "aegis/gateway/objects/user.hpp"
15 #include <nlohmann/json.hpp>
16 
17 namespace aegis
18 {
19 
20 namespace gateway
21 {
22 
23 namespace objects
24 {
25 
29 {
32  std::string nick;
33  std::vector<snowflake> roles;
34  std::string joined_at;
35  bool deaf = false;
36  bool mute = false;
37 };
38 
40 inline void from_json(const nlohmann::json& j, guild_member& m)
41 {
42  m._user = j["user"];
43  if (j.count("nick") && !j["nick"].is_null())
44  m.nick = j["nick"].get<std::string>();
45  if (j.count("guild_id") && !j["guild_id"].is_null())
46  m.guild_id = j["guild_id"];
47  if (j.count("roles") && !j["roles"].is_null())
48  for (const auto & _role : j["roles"])
49  m.roles.push_back(_role);
50  if (j.count("joined_at"))
51  m.joined_at = j["joined_at"].get<std::string>();
52  if (j.count("deaf"))
53  m.deaf = j["deaf"];
54  if (j.count("mute"))
55  m.mute = j["mute"];
56 }
58 
59 }
60 
61 }
62 
63 }
bool deaf
Definition: guild_member.hpp:35
Stores creation time and extra data specific to Discord for entities.
Definition: snowflake.hpp:21
Definition: user.hpp:35
Definition: guild_member.hpp:28
std::string joined_at
Definition: guild_member.hpp:34
snowflake guild_id
Definition: guild_member.hpp:31
std::vector< snowflake > roles
Definition: guild_member.hpp:33
bool mute
Definition: guild_member.hpp:36
objects::user _user
Definition: guild_member.hpp:30
std::string nick
Definition: guild_member.hpp:32