12 #include "aegis/config.hpp"
13 #include "aegis/snowflake.hpp"
14 #include "aegis/gateway/objects/timestamp.hpp"
15 #include "aegis/gateway/objects/party.hpp"
16 #include "aegis/gateway/objects/asset.hpp"
17 #include "aegis/gateway/objects/secret.hpp"
18 #include <nlohmann/json.hpp>
51 activity_type type = activity_type::Game;
65 inline void from_json(
const nlohmann::json& j,
activity& m)
67 if (j.count(
"name") && !j[
"name"].is_null())
68 m.name = j[
"name"].get<std::string>();
69 if (j.count(
"type") && !j[
"type"].is_null())
70 m.type = static_cast<objects::activity::activity_type>(j[
"type"].get<int32_t>());
71 if (j.count(
"url") && !j[
"url"].is_null())
72 m.url = j[
"url"].get<std::string>();
73 if (j.count(
"timestamps") && !j[
"timestamps"].is_null())
74 m.timestamps = j[
"timestamps"];
75 if (j.count(
"party") && !j[
"party"].is_null())
76 m.party_data = j[
"party"];
77 if (j.count(
"assets") && !j[
"assets"].is_null())
78 m.assets = j[
"assets"];
79 if (j.count(
"secrets") && !j[
"secrets"].is_null())
80 m.secrets = j[
"secrets"];
81 if (j.count(
"application_id") && !j[
"application_id"].is_null())
82 m.application_id = j[
"application_id"];
83 if (j.count(
"details") && !j[
"details"].is_null())
84 m.details = j[
"details"].get<std::string>();
85 if (j.count(
"state") && !j[
"state"].is_null())
86 m.state = j[
"state"].get<std::string>();
87 if (j.count(
"instance") && !j[
"instance"].is_null())
88 m.instance = j[
"instance"];
89 if (j.count(
"flags") && !j[
"flags"].is_null())
93 inline void to_json(nlohmann::json& j,
const activity& m)
96 j[
"type"] =
static_cast<int32_t
>(m.type);
99 j[
"flags"] =
static_cast<int32_t
>(m.flags);
101 if (m.type == activity::Streaming || m.type == activity::Watching)
103 if (m.type == activity::Game)
105 if (!m.details.empty())
106 j[
"details"] = m.details;
107 if (!m.state.empty())
108 j[
"state"] = m.state;
109 j[
"party"] = m.party_data;
110 j[
"assets"] = m.assets;
111 j[
"secrets"] = m.secrets;
112 j[
"application_id"] = m.application_id;
113 j[
"instance"] = m.instance;
Definition: secret.hpp:26
Stores creation time and extra data specific to Discord for entities.
Definition: snowflake.hpp:21
Definition: timestamp.hpp:26
Definition: activity.hpp:31