read embed json

This commit is contained in:
ouwou 2020-08-27 18:50:53 -04:00
parent 34b572db40
commit 8699a547f3
2 changed files with 120 additions and 1 deletions

View File

@ -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;

View File

@ -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<EmbedFieldData> 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<RoleData> MentionRoles; //
// std::vector<ChannelMentionData> MentionChannels; // opt
// std::vector<AttachmentData> Attachments; //
// std::vector<EmbedData> Embeds; //
std::vector<EmbedData> Embeds; //
// std::vector<ReactionData> Reactions; // opt
std::string Nonce; // opt
bool IsPinned; //