diff options
author | Dylam De La Torre <DyXel04@gmail.com> | 2021-11-23 05:21:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 04:21:56 +0000 |
commit | a51a54bc5979a2491f152abc47ad54e6b63f27c8 (patch) | |
tree | ce67092b2f6df366033a65a6111e4650866766b2 /src/discord/sticker.cpp | |
parent | d88079000a79e6bcbe51c5a2868d57b303b5fcb6 (diff) | |
download | abaddon-portaudio-a51a54bc5979a2491f152abc47ad54e6b63f27c8.tar.gz abaddon-portaudio-a51a54bc5979a2491f152abc47ad54e6b63f27c8.zip |
Restructure source and resource files (#46)
importantly, res is now res/res and css is now res/css
Diffstat (limited to 'src/discord/sticker.cpp')
-rw-r--r-- | src/discord/sticker.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/discord/sticker.cpp b/src/discord/sticker.cpp new file mode 100644 index 0000000..b92d031 --- /dev/null +++ b/src/discord/sticker.cpp @@ -0,0 +1,52 @@ +#include "sticker.hpp" + +void to_json(nlohmann::json &j, const StickerData &m) { + j["id"] = m.ID; + j["pack_id"] = m.PackID; + j["name"] = m.Name; + j["description"] = m.Description; + JS_IF("tags", m.Tags); + JS_IF("asset", m.AssetHash); + JS_IF("preview_asset", m.PreviewAssetHash); + j["format_type"] = m.FormatType; +} + +void from_json(const nlohmann::json &j, StickerData &m) { + JS_D("id", m.ID); + JS_D("pack_id", m.PackID); + JS_D("name", m.Name); + JS_D("description", m.Description); + JS_O("tags", m.Tags); + JS_O("asset", m.AssetHash); + JS_ON("preview_asset", m.PreviewAssetHash); + JS_D("format_type", m.FormatType); +} + +std::string StickerData::GetURL() const { + if (!AssetHash.has_value()) return ""; + if (FormatType == StickerFormatType::PNG || FormatType == StickerFormatType::APNG) + return "https://media.discordapp.net/stickers/" + std::to_string(ID) + "/" + *AssetHash + ".png?size=256"; + else if (FormatType == StickerFormatType::LOTTIE) + return "https://media.discordapp.net/stickers/" + std::to_string(ID) + "/" + *AssetHash + ".json"; + return ""; +} + +void to_json(nlohmann::json &j, const StickerItem &m) { + j["id"] = m.ID; + j["name"] = m.Name; + j["format_type"] = m.FormatType; +} + +void from_json(const nlohmann::json &j, StickerItem &m) { + JS_D("id", m.ID); + JS_D("name", m.Name); + JS_D("format_type", m.FormatType); +} + +std::string StickerItem::GetURL() const { + if (FormatType == StickerFormatType::PNG || FormatType == StickerFormatType::APNG) + return "https://media.discordapp.net/stickers/" + std::to_string(ID) + ".png?size=256"; + else if (FormatType == StickerFormatType::LOTTIE) + return "https://media.discordapp.net/stickers/" + std::to_string(ID) + ".json"; + return ""; +} |