#pragma once #include "snowflake.hpp" #include "json.hpp" #include "user.hpp" #include "sticker.hpp" #include "emoji.hpp" #include "member.hpp" #include #include enum class MessageType { DEFAULT = 0, // yep RECIPIENT_ADD = 1, // yep RECIPIENT_REMOVE = 2, // yep CALL = 3, // nope CHANNEL_NAME_CHANGE = 4, // nope CHANNEL_ICON_CHANGE = 5, // nope CHANNEL_PINNED_MESSAGE = 6, // yep GUILD_MEMBER_JOIN = 7, // yep USER_PREMIUM_GUILD_SUBSCRIPTION = 8, // nope USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = 9, // nope USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 10, // nope USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11, // nope CHANNEL_FOLLOW_ADD = 12, // nope GUILD_DISCOVERY_DISQUALIFIED = 14, // nope GUILD_DISCOVERY_REQUALIFIED = 15, // nope INLINE_REPLY = 19, // kinda APPLICATION_COMMAND = 20, // yep }; enum class MessageFlags { NONE = 0, CROSSPOSTED = 1 << 0, IS_CROSSPOST = 1 << 1, SUPPRESS_EMBEDS = 1 << 2, SOURCE_MESSAGE_DELETE = 1 << 3, URGENT = 1 << 4, }; struct EmbedFooterData { std::string Text; std::optional IconURL; std::optional ProxyIconURL; friend void to_json(nlohmann::json &j, const EmbedFooterData &m); friend void from_json(const nlohmann::json &j, EmbedFooterData &m); }; struct EmbedImageData { std::optional URL; std::optional ProxyURL; std::optional Height; std::optional Width; friend void to_json(nlohmann::json &j, const EmbedImageData &m); friend void from_json(const nlohmann::json &j, EmbedImageData &m); }; struct EmbedThumbnailData { std::optional URL; std::optional ProxyURL; std::optional Height; std::optional Width; friend void to_json(nlohmann::json &j, const EmbedThumbnailData &m); friend void from_json(const nlohmann::json &j, EmbedThumbnailData &m); }; struct EmbedVideoData { std::optional URL; std::optional Height; std::optional Width; friend void to_json(nlohmann::json &j, const EmbedVideoData &m); friend void from_json(const nlohmann::json &j, EmbedVideoData &m); }; struct EmbedProviderData { std::optional Name; std::optional URL; // null friend void to_json(nlohmann::json &j, const EmbedProviderData &m); friend void from_json(const nlohmann::json &j, EmbedProviderData &m); }; struct EmbedAuthorData { std::optional Name; std::optional URL; std::optional IconURL; std::optional ProxyIconURL; friend void to_json(nlohmann::json &j, const EmbedAuthorData &m); friend void from_json(const nlohmann::json &j, EmbedAuthorData &m); }; struct EmbedFieldData { std::string Name; std::string Value; std::optional Inline; friend void to_json(nlohmann::json &j, const EmbedFieldData &m); friend void from_json(const nlohmann::json &j, EmbedFieldData &m); }; struct EmbedData { std::optional Title; std::optional Type; std::optional Description; std::optional URL; std::optional Timestamp; std::optional Color; std::optional Footer; std::optional Image; std::optional Thumbnail; std::optional Video; std::optional Provider; std::optional Author; std::optional> Fields; friend void to_json(nlohmann::json &j, const EmbedData &m); friend void from_json(const nlohmann::json &j, EmbedData &m); }; struct AttachmentData { Snowflake ID; std::string Filename; int Bytes; std::string URL; std::string ProxyURL; std::optional Height; // null std::optional Width; // null friend void to_json(nlohmann::json &j, const AttachmentData &m); friend void from_json(const nlohmann::json &j, AttachmentData &m); }; struct MessageReferenceData { std::optional MessageID; std::optional ChannelID; std::optional GuildID; friend void from_json(const nlohmann::json &j, MessageReferenceData &m); friend void to_json(nlohmann::json &j, const MessageReferenceData &m); }; struct ReactionData { int Count; bool HasReactedWith; EmojiData Emoji; friend void from_json(const nlohmann::json &j, ReactionData &m); friend void to_json(nlohmann::json &j, const ReactionData &m); }; struct MessageApplicationData { Snowflake ID; std::optional CoverImage; std::string Description; std::string Icon; // null std::string Name; friend void from_json(const nlohmann::json &j, MessageApplicationData &m); friend void to_json(nlohmann::json &j, const MessageApplicationData &m); }; struct Message { Snowflake ID; Snowflake ChannelID; std::optional GuildID; UserData Author; std::optional Member; std::string Content; std::string Timestamp; std::string EditedTimestamp; // null bool IsTTS; bool DoesMentionEveryone; std::vector Mentions; // full user accessible // std::vector MentionRoles; // std::optional> MentionChannels; std::vector Attachments; std::vector Embeds; std::optional> Reactions; std::optional Nonce; bool IsPinned; std::optional WebhookID; MessageType Type; // std::optional ActivityData; std::optional Application; std::optional MessageReference; std::optional Flags = MessageFlags::NONE; std::optional> Stickers; std::optional> ReferencedMessage; // has_value && null means deleted friend void from_json(const nlohmann::json &j, Message &m); void from_json_edited(const nlohmann::json &j); // for MESSAGE_UPDATE // custom fields to track changes void SetDeleted(); void SetEdited(); bool IsDeleted() const; bool IsEdited() const; private: bool m_deleted = false; bool m_edited = false; };