12 #include "aegis/config.hpp"
13 #include "aegis/snowflake.hpp"
14 #include "aegis/gateway/objects/user.hpp"
15 #include "permission_overwrite.hpp"
16 #include <nlohmann/json.hpp>
28 void from_json(
const nlohmann::json& j, channel& m);
29 void to_json(nlohmann::json& j,
const channel& m);
37 from_json(nlohmann::json::parse(_json), *
this);
42 from_json(_json, *
this);
79 inline void from_json(
const nlohmann::json& j,
channel& m)
83 if (j.count(
"guild_id") && !j[
"guild_id"].is_null())
85 if (j.count(
"position") && !j[
"position"].is_null())
87 if (j.count(
"permission_overwrites") && !j[
"permission_overwrites"].is_null())
88 for (
const auto & i : j[
"permission_overwrites"])
90 if (j.count(
"name") && !j[
"name"].is_null())
91 m.
name = j[
"name"].get<std::string>();
92 if (j.count(
"topic") && !j[
"topic"].is_null())
93 m.
topic = j[
"topic"].get<std::string>();
94 if (j.count(
"nsfw") && !j[
"nsfw"].is_null())
96 if (j.count(
"last_message_id") && !j[
"last_message_id"].is_null())
98 if (j.count(
"bitrate") && !j[
"bitrate"].is_null())
100 if (j.count(
"userlimit") && !j[
"userlimit"].is_null())
102 if (j.count(
"icon") && !j[
"icon"].is_null())
103 m.
icon = j[
"icon"].get<std::string>();
104 if (j.count(
"owner_id") && !j[
"owner_id"].is_null())
106 if (j.count(
"application_id") && !j[
"application_id"].is_null())
108 if (j.count(
"parent_id") && !j[
"parent_id"].is_null())
110 if (j.count(
"recipients") && !j[
"recipients"].is_null())
111 for (
const auto & i : j[
"recipients"])
115 inline void to_json(nlohmann::json& j,
const channel& m)
118 j[
"id"] = std::to_string(m.id);
121 j[
"guild_id"] = m.guild_id;
123 j[
"position"] = m.position;
125 if (!m.topic.empty())
126 j[
"topic"] = m.topic;
129 if (m.last_message_id)
130 j[
"last_message_id"] = m.last_message_id;
132 j[
"bitrate"] = m.bitrate;
134 j[
"userlimit"] = m.userlimit;
138 j[
"owner_id"] = m.owner_id;
139 if (m.application_id)
140 j[
"application_id"] = m.application_id;
142 j[
"parent_id"] = m.parent_id;
144 if (!m.permission_overwrites.empty())
145 for (
auto i : m.permission_overwrites)
146 j[
"permission_overwrites"].push_back(i);
148 if (!m.recipients.empty())
149 for (
auto i : m.recipients)
150 j[
"recipients"].push_back(i);
Stores creation time and extra data specific to Discord for entities.
Definition: snowflake.hpp:21
snowflake application_id
Definition: channel.hpp:74
int bitrate
Definition: channel.hpp:69
std::vector< objects::permission_overwrite > permission_overwrites
Definition: channel.hpp:64
Definition: channel.hpp:52
Primary class for managing a bot interface.
Definition: core.hpp:157
Class for performing actions pertaining to a specified channel.
Definition: channel.hpp:170
Definition: channel.hpp:55
snowflake owner_id
Definition: channel.hpp:73
int position
Definition: channel.hpp:63
Definition: channel.hpp:54
std::string icon
Definition: channel.hpp:72
snowflake channel_id
Definition: channel.hpp:60
std::string name
Definition: channel.hpp:65
std::string topic
Definition: channel.hpp:66
bool nsfw
Definition: channel.hpp:67
bool nsfw() const noexcept
Get if this channel is set to NSFW.
Definition: channel.hpp:600
snowflake last_message_id
Definition: channel.hpp:68
std::vector< objects::user > recipients
Definition: channel.hpp:71
channel_type
Enumeration of the channel types.
Definition: channel.hpp:50
Represents a guild or DM channel within Discord.
Definition: channel.hpp:33
Definition: channel.hpp:56
channel_type type
Definition: channel.hpp:61
int userlimit
Definition: channel.hpp:70
snowflake guild_id
Definition: channel.hpp:62
Definition: channel.hpp:53
snowflake parent_id
Definition: channel.hpp:75
snowflake id
Definition: channel.hpp:59