From cbc65bf766c1241980961bcca999adf69c80dba0 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 1 Jul 2021 02:03:41 -0400 Subject: re-add suppport for static (a)png stickers --- discord/sticker.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'discord/sticker.cpp') diff --git a/discord/sticker.cpp b/discord/sticker.cpp index 8e50a47..b92d031 100644 --- a/discord/sticker.cpp +++ b/discord/sticker.cpp @@ -30,3 +30,23 @@ std::string StickerData::GetURL() const { 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 ""; +} -- cgit v1.2.3