summaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-12-22 22:32:05 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2020-12-22 22:32:05 -0500
commitcb18543c503320cf9d2132b0077625acb0e78e51 (patch)
tree0fc86a50ede211967658f619e4d5513d8ae033e2 /discord
parent2e2ed5fc8f5192f082603f108fbe9a1fdaf39707 (diff)
downloadabaddon-portaudio-cb18543c503320cf9d2132b0077625acb0e78e51.tar.gz
abaddon-portaudio-cb18543c503320cf9d2132b0077625acb0e78e51.zip
show RECIPIENT_ADD, RECIPIENT_REMOVE messages
Diffstat (limited to 'discord')
-rw-r--r--discord/discord.cpp3
-rw-r--r--discord/message.hpp2
-rw-r--r--discord/store.cpp13
-rw-r--r--discord/user.cpp20
-rw-r--r--discord/user.hpp8
5 files changed, 29 insertions, 17 deletions
diff --git a/discord/discord.cpp b/discord/discord.cpp
index bdb8fbb..4ddad12 100644
--- a/discord/discord.cpp
+++ b/discord/discord.cpp
@@ -1030,6 +1030,9 @@ void DiscordClient::StoreMessageData(const Message &msg) {
if (!cur.has_value())
m_store.SetEmoji(r.Emoji.ID, r.Emoji);
}
+
+ for (const auto &user : msg.Mentions)
+ m_store.SetUser(user.ID, user);
}
void DiscordClient::LoadEventMap() {
diff --git a/discord/message.hpp b/discord/message.hpp
index af6fb12..5968c99 100644
--- a/discord/message.hpp
+++ b/discord/message.hpp
@@ -173,7 +173,7 @@ struct Message {
std::string EditedTimestamp; // null
bool IsTTS;
bool DoesMentionEveryone;
- std::vector<User> Mentions; // currently discarded in store
+ std::vector<User> Mentions; // full user accessible
// std::vector<Role> MentionRoles;
// std::optional<std::vector<ChannelMentionData>> MentionChannels;
std::vector<AttachmentData> Attachments;
diff --git a/discord/store.cpp b/discord/store.cpp
index 6024046..ef23eca 100644
--- a/discord/store.cpp
+++ b/discord/store.cpp
@@ -189,16 +189,9 @@ void Store::SetMessage(Snowflake id, const Message &message) {
Bind(m_set_msg_stmt, 7, message.EditedTimestamp);
Bind(m_set_msg_stmt, 8, message.IsTTS);
Bind(m_set_msg_stmt, 9, message.DoesMentionEveryone);
- Bind(m_set_msg_stmt, 10, "[]"s); // mentions, a const char* literal will call the bool overload instead of std::string
- {
- std::string tmp;
- tmp = nlohmann::json(message.Attachments).dump();
- Bind(m_set_msg_stmt, 11, tmp);
- }
- {
- std::string tmp = nlohmann::json(message.Embeds).dump();
- Bind(m_set_msg_stmt, 12, tmp);
- }
+ Bind(m_set_msg_stmt, 10, nlohmann::json(message.Mentions).dump());
+ Bind(m_set_msg_stmt, 11, nlohmann::json(message.Attachments).dump());
+ Bind(m_set_msg_stmt, 12, nlohmann::json(message.Embeds).dump());
Bind(m_set_msg_stmt, 13, message.IsPinned);
Bind(m_set_msg_stmt, 14, message.WebhookID);
Bind(m_set_msg_stmt, 15, static_cast<uint64_t>(message.Type));
diff --git a/discord/user.cpp b/discord/user.cpp
index 580f2ac..e4532ba 100644
--- a/discord/user.cpp
+++ b/discord/user.cpp
@@ -44,8 +44,24 @@ void from_json(const nlohmann::json &j, User &m) {
void to_json(nlohmann::json &j, const User &m) {
j["id"] = m.ID;
j["username"] = m.Username;
- j["avatar"] = m.Avatar;
- // rest of stuff as needed im too lazy and its probably not necessary
+ j["discriminator"] = m.Discriminator;
+ if (m.Avatar == "")
+ j["avatar"] = nullptr;
+ else
+ j["avatar"] = m.Avatar;
+ JS_IF("bot", m.IsBot);
+ JS_IF("system", m.IsSystem);
+ JS_IF("mfa_enabled", m.IsMFAEnabled);
+ JS_IF("locale", m.Locale);
+ JS_IF("verified", m.IsVerified);
+ JS_IF("email", m.Email);
+ JS_IF("flags", m.Flags);
+ JS_IF("premium_type", m.PremiumType);
+ JS_IF("public_flags", m.PublicFlags);
+ JS_IF("desktop", m.IsDesktop);
+ JS_IF("mobile", m.IsMobile);
+ JS_IF("nsfw_allowed", m.IsNSFWAllowed);
+ JS_IF("phone", m.Phone);
}
void User::update_from_json(const nlohmann::json &j, User &m) {
diff --git a/discord/user.hpp b/discord/user.hpp
index 2427b0b..cf6c2fa 100644
--- a/discord/user.hpp
+++ b/discord/user.hpp
@@ -19,10 +19,10 @@ struct User {
std::optional<int> PublicFlags;
// undocumented (opt)
- bool IsDesktop = false; //
- bool IsMobile = false; //
- bool IsNSFWAllowed = false; // null
- std::string Phone; // null?
+ std::optional<bool> IsDesktop;
+ std::optional<bool> IsMobile;
+ std::optional<bool> IsNSFWAllowed; // null
+ std::optional<std::string> Phone; // null?
friend void from_json(const nlohmann::json &j, User &m);
friend void to_json(nlohmann::json &j, const User &m);