From 8699a547f3d51504cd0aa695f580315b8fe27678 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 27 Aug 2020 18:50:53 -0400 Subject: read embed json --- discord/discord.cpp | 44 ++++++++++++++++++++++++++++++ discord/discord.hpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 120 insertions(+), 1 deletion(-) (limited to 'discord') diff --git a/discord/discord.cpp b/discord/discord.cpp index 15a719c..66e449c 100644 --- a/discord/discord.cpp +++ b/discord/discord.cpp @@ -494,6 +494,50 @@ void from_json(const nlohmann::json &j, UserSettingsData &m) { JS_D("afk_timeout", m.AFKTimeout); } +void from_json(const nlohmann::json &j, EmbedFooterData &m) { + JS_D("text", m.Text); + JS_O("icon_url", m.IconURL); + JS_O("proxy_icon_url", m.ProxyIconURL); +} + +void from_json(const nlohmann::json &j, EmbedImageData &m) { + JS_O("url", m.URL); + JS_O("proxy_url", m.ProxyURL); + JS_O("height", m.Height); + JS_O("width", m.Width); +} + +void from_json(const nlohmann::json &j, EmbedThumbnailData &m) { + JS_O("url", m.URL); + JS_O("proxy_url", m.ProxyURL); + JS_O("height", m.Height); + JS_O("width", m.Width); +} + +void from_json(const nlohmann::json &j, EmbedVideoData &m) { + JS_O("url", m.URL); + JS_O("height", m.Height); + JS_O("width", m.Width); +} + +void from_json(const nlohmann::json &j, EmbedProviderData &m) { + JS_O("name", m.Name); + JS_O("url", m.URL); +} + +void from_json(const nlohmann::json &j, EmbedAuthorData &m) { + JS_O("name", m.Name); + JS_O("url", m.URL); + JS_O("icon_url", m.IconURL); + JS_O("proxy_icon_url", m.ProxyIconURL); +} + +void from_json(const nlohmann::json &j, EmbedFieldData &m) { + JS_D("name", m.Name); + JS_D("value", m.Value); + JS_O("inline", m.Inline); +} + void to_json(nlohmann::json &j, const IdentifyProperties &m) { j["$os"] = m.OS; j["$browser"] = m.Browser; diff --git a/discord/discord.hpp b/discord/discord.hpp index 3a98b40..81f8b42 100644 --- a/discord/discord.hpp +++ b/discord/discord.hpp @@ -268,6 +268,81 @@ enum class MessageFlags { URGENT = 1 << 4, }; +struct EmbedFooterData { + std::string Text; // + std::string IconURL; // opt + std::string ProxyIconURL; // opt + + friend void from_json(const nlohmann::json &j, EmbedFooterData &m); +}; + +struct EmbedImageData { + std::string URL; // opt + std::string ProxyURL; // opt + int Height = 0; // opt + int Width = 0; // opt + + friend void from_json(const nlohmann::json &j, EmbedImageData &m); +}; + +struct EmbedThumbnailData { + std::string URL; // opt + std::string ProxyURL; // opt + int Height = 0; // opt + int Width = 0; // opt + + friend void from_json(const nlohmann::json &j, EmbedThumbnailData &m); +}; + +struct EmbedVideoData { + std::string URL; // opt + int Height = 0; // opt + int Width = 0; // opt + friend void from_json(const nlohmann::json &j, EmbedVideoData &m); +}; + +struct EmbedProviderData { + std::string Name; // opt + std::string URL; // opt + + friend void from_json(const nlohmann::json &j, EmbedProviderData &m); +}; + +struct EmbedAuthorData { + std::string Name; // opt + std::string URL; // opt + std::string IconURL; // opt + std::string ProxyIconURL; // opt + + friend void from_json(const nlohmann::json &j, EmbedAuthorData &m); +}; + +struct EmbedFieldData { + std::string Name; // + std::string Value; // + bool Inline = false; // opt + + friend void from_json(const nlohmann::json &j, EmbedFieldData &m); +}; + +struct EmbedData { + std::string Title; // opt + std::string Type; // opt + std::string Description; // opt + std::string URL; // opt + std::string Timestamp; // opt + int Color = 0; // opt + EmbedFooterData Footer; // opt + EmbedImageData Image; // opt + EmbedThumbnailData Thumbnail; // opt + EmbedVideoData Video; // opt + EmbedProviderData Provider; // opt + EmbedAuthorData Author; // opt + std::vector Fields; // opt + + friend void from_json(const nlohmann::json &j, EmbedData &m); +}; + struct MessageData { Snowflake ID; // Snowflake ChannelID; // @@ -283,7 +358,7 @@ struct MessageData { // std::vector MentionRoles; // // std::vector MentionChannels; // opt // std::vector Attachments; // - // std::vector Embeds; // + std::vector Embeds; // // std::vector Reactions; // opt std::string Nonce; // opt bool IsPinned; // -- cgit v1.2.3