summaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-11-02 17:36:10 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2020-11-02 17:36:10 -0500
commitb97722e93775d8778400d42f30299d55682906f1 (patch)
treee497d0aafa7719208c219d88fc5e3901965be9a9 /discord
parent8efa2024582b0a2aeda72f3e6865a4562717eabc (diff)
downloadabaddon-portaudio-b97722e93775d8778400d42f30299d55682906f1.tar.gz
abaddon-portaudio-b97722e93775d8778400d42f30299d55682906f1.zip
show non-lottie stickers statically
Diffstat (limited to 'discord')
-rw-r--r--discord/message.cpp2
-rw-r--r--discord/message.hpp2
-rw-r--r--discord/objects.hpp1
-rw-r--r--discord/sticker.cpp21
-rw-r--r--discord/sticker.hpp28
5 files changed, 54 insertions, 0 deletions
diff --git a/discord/message.cpp b/discord/message.cpp
index 6deb63a..66b806f 100644
--- a/discord/message.cpp
+++ b/discord/message.cpp
@@ -109,6 +109,7 @@ void from_json(const nlohmann::json &j, Message &m) {
// JS_O("application", m.Application);
// JS_O("message_reference", m.MessageReference);
JS_O("flags", m.Flags);
+ JS_O("stickers", m.Stickers);
}
void Message::from_json_edited(const nlohmann::json &j) {
@@ -130,6 +131,7 @@ void Message::from_json_edited(const nlohmann::json &j) {
JS_O("webhook_id", WebhookID);
JS_O("type", Type);
JS_O("flags", Flags);
+ JS_O("stickers", Stickers);
}
void Message::SetDeleted() {
diff --git a/discord/message.hpp b/discord/message.hpp
index 35adc3b..629fc9f 100644
--- a/discord/message.hpp
+++ b/discord/message.hpp
@@ -2,6 +2,7 @@
#include "snowflake.hpp"
#include "json.hpp"
#include "user.hpp"
+#include "sticker.hpp"
#include <string>
#include <vector>
@@ -154,6 +155,7 @@ struct Message {
// std::optional<MessageApplicationData> Application;
std::optional<MessageReferenceData> MessageReference;
std::optional<MessageFlags> Flags = MessageFlags::NONE;
+ std::optional<std::vector<Sticker>> Stickers;
friend void from_json(const nlohmann::json &j, Message &m);
void from_json_edited(const nlohmann::json &j); // for MESSAGE_UPDATE
diff --git a/discord/objects.hpp b/discord/objects.hpp
index d71c1fc..fd836b1 100644
--- a/discord/objects.hpp
+++ b/discord/objects.hpp
@@ -15,6 +15,7 @@
#include "permissions.hpp"
#include "emoji.hpp"
#include "activity.hpp"
+#include "sticker.hpp"
// most stuff below should just be objects that get processed and thrown away immediately
diff --git a/discord/sticker.cpp b/discord/sticker.cpp
new file mode 100644
index 0000000..1d59e82
--- /dev/null
+++ b/discord/sticker.cpp
@@ -0,0 +1,21 @@
+#include "sticker.hpp"
+
+void from_json(const nlohmann::json &j, Sticker &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_D("asset", m.AssetHash);
+ JS_N("preview_asset", m.PreviewAssetHash);
+ JS_D("format_type", m.FormatType);
+}
+
+std::string Sticker::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 "";
+}
diff --git a/discord/sticker.hpp b/discord/sticker.hpp
new file mode 100644
index 0000000..e510800
--- /dev/null
+++ b/discord/sticker.hpp
@@ -0,0 +1,28 @@
+#pragma once
+#include <optional>
+#include <string>
+#include "snowflake.hpp"
+#include "json.hpp"
+
+// unstable
+
+enum class StickerFormatType {
+ PNG = 1,
+ APNG = 2,
+ LOTTIE = 3,
+};
+
+struct Sticker {
+ Snowflake ID;
+ Snowflake PackID;
+ std::string Name;
+ std::string Description;
+ std::optional<std::string> Tags;
+ std::optional<std::string> AssetHash;
+ std::optional<std::string> PreviewAssetHash;
+ StickerFormatType FormatType;
+
+ friend void from_json(const nlohmann::json &j, Sticker &m);
+
+ std::string GetURL() const;
+};