summaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-11-01 17:10:25 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2020-11-01 17:10:25 -0500
commit77b187bd643fcf05f77a1a2524a9aadc8a4c2e03 (patch)
tree3c8be13709c35d19ce1e32c52f054541b377ede2 /discord
parent2d5439ba90265e10f1ed2476e6a46eb997bce16b (diff)
downloadabaddon-portaudio-77b187bd643fcf05f77a1a2524a9aadc8a4c2e03.tar.gz
abaddon-portaudio-77b187bd643fcf05f77a1a2524a9aadc8a4c2e03.zip
more optional + referencedata
Diffstat (limited to 'discord')
-rw-r--r--discord/discord.cpp6
-rw-r--r--discord/message.cpp12
-rw-r--r--discord/message.hpp56
3 files changed, 48 insertions, 26 deletions
diff --git a/discord/discord.cpp b/discord/discord.cpp
index 7c4d551..ecfd0a3 100644
--- a/discord/discord.cpp
+++ b/discord/discord.cpp
@@ -132,7 +132,7 @@ void DiscordClient::FetchMessagesInChannel(Snowflake id, std::function<void(cons
m_store.SetMessage(msg.ID, msg);
AddMessageToChannel(msg.ID, id);
m_store.SetUser(msg.Author.ID, msg.Author);
- AddUserToGuild(msg.Author.ID, msg.GuildID);
+ AddUserToGuild(msg.Author.ID, *msg.GuildID);
ids.push_back(msg.ID);
}
@@ -153,7 +153,7 @@ void DiscordClient::FetchMessagesInChannelBefore(Snowflake channel_id, Snowflake
m_store.SetMessage(msg.ID, msg);
AddMessageToChannel(msg.ID, channel_id);
m_store.SetUser(msg.Author.ID, msg.Author);
- AddUserToGuild(msg.Author.ID, msg.GuildID);
+ AddUserToGuild(msg.Author.ID, *msg.GuildID);
ids.push_back(msg.ID);
}
@@ -588,7 +588,7 @@ void DiscordClient::HandleGatewayMessageCreate(const GatewayMessage &msg) {
m_store.SetMessage(data.ID, data);
AddMessageToChannel(data.ID, data.ChannelID);
m_store.SetUser(data.Author.ID, data.Author);
- AddUserToGuild(data.Author.ID, data.GuildID);
+ AddUserToGuild(data.Author.ID, *data.GuildID);
m_signal_message_create.emit(data.ID);
}
diff --git a/discord/message.cpp b/discord/message.cpp
index 428281d..6deb63a 100644
--- a/discord/message.cpp
+++ b/discord/message.cpp
@@ -70,6 +70,18 @@ void from_json(const nlohmann::json &j, AttachmentData &m) {
JS_ON("width", m.Width);
}
+void from_json(const nlohmann::json &j, MessageReferenceData &m) {
+ JS_O("message_id", m.MessageID);
+ JS_O("channel_id", m.ChannelID);
+ JS_O("guild_id", m.GuildID);
+}
+
+void to_json(nlohmann::json &j, const MessageReferenceData &m) {
+ JS_IF("message_id", m.MessageID);
+ JS_IF("channel_id", m.ChannelID);
+ JS_IF("guild_id", m.GuildID);
+}
+
void from_json(const nlohmann::json &j, Message &m) {
JS_D("id", m.ID);
JS_D("channel_id", m.ChannelID);
diff --git a/discord/message.hpp b/discord/message.hpp
index a609742..35adc3b 100644
--- a/discord/message.hpp
+++ b/discord/message.hpp
@@ -21,6 +21,7 @@ enum class MessageType {
CHANNEL_FOLLOW_ADD = 12,
GUILD_DISCOVERY_DISQUALIFIED = 14,
GUILD_DISCOVERY_REQUALIFIED = 15,
+ INLINE_REPLY = 19,
};
enum class MessageFlags {
@@ -119,31 +120,40 @@ struct AttachmentData {
friend void from_json(const nlohmann::json &j, AttachmentData &m);
};
+struct MessageReferenceData {
+ std::optional<Snowflake> MessageID;
+ std::optional<Snowflake> ChannelID;
+ std::optional<Snowflake> GuildID;
+
+ friend void from_json(const nlohmann::json &j, MessageReferenceData &m);
+ friend void to_json(nlohmann::json &j, const MessageReferenceData &m);
+};
+
struct Message {
- Snowflake ID; //
- Snowflake ChannelID; //
- Snowflake GuildID; // opt
- User Author; //
- // GuildMember Member; // opt
- std::string Content; //
- std::string Timestamp; //
+ Snowflake ID;
+ Snowflake ChannelID;
+ std::optional<Snowflake> GuildID;
+ User Author;
+ // std::optional<GuildMember> Member;
+ std::string Content;
+ std::string Timestamp;
std::string EditedTimestamp; // null
- bool IsTTS; //
- bool DoesMentionEveryone; //
- std::vector<User> Mentions; //
- // std::vector<Role> MentionRoles; //
- // std::vector<ChannelMentionData> MentionChannels; // opt
- std::vector<AttachmentData> Attachments; //
- std::vector<EmbedData> Embeds; //
- // std::vector<ReactionData> Reactions; // opt
- std::string Nonce; // opt
- bool IsPinned; //
- Snowflake WebhookID; // opt
- MessageType Type; //
- // MessageActivityData Activity; // opt
- // MessageApplicationData Application; // opt
- // MessageReferenceData MessageReference; // opt
- MessageFlags Flags = MessageFlags::NONE; // opt
+ bool IsTTS;
+ bool DoesMentionEveryone;
+ std::vector<User> Mentions;
+ // std::vector<Role> MentionRoles;
+ // std::optional<std::vector<ChannelMentionData>> MentionChannels;
+ std::vector<AttachmentData> Attachments;
+ std::vector<EmbedData> Embeds;
+ // std::optional<std::vector<ReactionData>> Reactions;
+ std::optional<std::string> Nonce;
+ bool IsPinned;
+ std::optional<Snowflake> WebhookID;
+ MessageType Type;
+ // std::optional<MessageActivityData> Activity;
+ // std::optional<MessageApplicationData> Application;
+ std::optional<MessageReferenceData> MessageReference;
+ std::optional<MessageFlags> Flags = MessageFlags::NONE;
friend void from_json(const nlohmann::json &j, Message &m);
void from_json_edited(const nlohmann::json &j); // for MESSAGE_UPDATE