deserialize message attachments for the future

This commit is contained in:
ouwou 2020-09-10 01:15:44 -04:00
parent 6ae9cc915d
commit fc389441f8
2 changed files with 24 additions and 2 deletions

View File

@ -60,6 +60,16 @@ void from_json(const nlohmann::json &j, EmbedData &m) {
JS_O("fields", m.Fields);
}
void from_json(const nlohmann::json &j, AttachmentData &m) {
JS_D("id", m.ID);
JS_D("filename", m.Filename);
JS_D("size", m.Bytes);
JS_D("url", m.URL);
JS_D("proxy_url", m.ProxyURL);
JS_N("height", m.Height);
JS_N("width", m.Width);
}
void from_json(const nlohmann::json &j, Message &m) {
JS_D("id", m.ID);
JS_D("channel_id", m.ChannelID);

View File

@ -107,6 +107,18 @@ struct EmbedData {
friend void from_json(const nlohmann::json &j, EmbedData &m);
};
struct AttachmentData {
Snowflake ID; //
std::string Filename; //
int Bytes; //
std::string URL; //
std::string ProxyURL; //
int Height = -1; // null
int Width = -1; // null
friend void from_json(const nlohmann::json &j, AttachmentData &m);
};
struct Message {
Snowflake ID; //
Snowflake ChannelID; //
@ -121,8 +133,8 @@ struct Message {
std::vector<User> Mentions; //
// std::vector<Role> MentionRoles; //
// std::vector<ChannelMentionData> MentionChannels; // opt
// std::vector<AttachmentData> Attachments; //
std::vector<EmbedData> Embeds; //
std::vector<AttachmentData> Attachments; //
std::vector<EmbedData> Embeds; //
// std::vector<ReactionData> Reactions; // opt
std::string Nonce; // opt
bool IsPinned; //