aegis.cpp
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
voice_state.hpp
1 //
2 // voice_state.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/member.hpp"
15 #include <nlohmann/json.hpp>
16 #include <string>
17 #include <vector>
18 
19 namespace aegis
20 {
21 
22 namespace gateway
23 {
24 
25 namespace objects
26 {
27 
31 {
32  snowflake guild_id;
33  snowflake channel_id;
34  snowflake user_id;
35  objects::member * _member = nullptr;
36  std::string session_id;
37  bool deaf = false;
38  bool mute = false;
39  bool self_deaf = false;
40  bool self_mute = false;
41  bool suppress = false;
42  bool self_stream = false;
43 };
44 
46 inline void from_json(const nlohmann::json& j, voice_state& m)
47 {
48  if(j.count("guild_id") && !j["guild_id"].is_null()) {
49  m.guild_id = j["guild_id"];
50  }
51  // todo: member
52  if(j.count("channel_id") && !j["channel_id"].is_null()) {
53  m.channel_id = j["channel_id"];
54  }
55  if(j.count("user_id") && !j["user_id"].is_null()) {
56  m.user_id = j["user_id"];
57  }
58  if(j.count("session_id") && !j["session_id"].is_null()) {
59  m.session_id = j["session_id"];
60  }
61  if(j.count("deaf") && !j["deaf"].is_null()) {
62  m.deaf = j["deaf"];
63  }
64  if(j.count("mute") && !j["mute"].is_null()) {
65  m.mute = j["mute"];
66  }
67  if(j.count("self_deaf") && !j["self_deaf"].is_null()) {
68  m.self_deaf = j["self_deaf"];
69  }
70  if(j.count("self_mute") && !j["self_mute"].is_null()) {
71  m.self_mute = j["self_mute"];
72  }
73  if(j.count("suppress") && !j["suppress"].is_null()) {
74  m.suppress = j["suppress"];
75  }
76  if(j.count("self_stream") && !j["self_stream"].is_null()) {
77  m.self_stream = j["self_stream"];
78  }
79 
80 }
81 
82 inline void to_json(nlohmann::json& j, const voice_state& m)
83 {
84  j["guild_id"] = m.guild_id;
85  j["chanel_id"] = m.channel_id;
86  j["user_id"] = m.user_id;
87  j["member"] = NULL;
88  j["session_id"] = m.session_id;
89  j["deaf"] = m.deaf;
90  j["mute"] = m.mute;
91  j["self_deaf"] = m.self_deaf;
92  j["self_mute"] = m.self_mute;
93  j["suppress"] = m.suppress;
94  j["self_stream"] = m.self_stream;
95 }
97 
98 }
99 
100 }
101 
102 }
Stores creation time and extra data specific to Discord for entities.
Definition: snowflake.hpp:21
Definition: member.hpp:35
Definition: voice_state.hpp:30