forked from OpenGamers/abaddon
move discord json stuff to separate file
This commit is contained in:
@@ -151,6 +151,7 @@
|
|||||||
<ClCompile Include="dialogs\token.cpp" />
|
<ClCompile Include="dialogs\token.cpp" />
|
||||||
<ClCompile Include="discord\discord.cpp" />
|
<ClCompile Include="discord\discord.cpp" />
|
||||||
<ClCompile Include="discord\http.cpp" />
|
<ClCompile Include="discord\http.cpp" />
|
||||||
|
<ClCompile Include="discord\objects.cpp" />
|
||||||
<ClCompile Include="discord\websocket.cpp" />
|
<ClCompile Include="discord\websocket.cpp" />
|
||||||
<ClCompile Include="settings.cpp" />
|
<ClCompile Include="settings.cpp" />
|
||||||
<ClCompile Include="windows\mainwindow.cpp" />
|
<ClCompile Include="windows\mainwindow.cpp" />
|
||||||
@@ -164,6 +165,7 @@
|
|||||||
<ClInclude Include="dialogs\token.hpp" />
|
<ClInclude Include="dialogs\token.hpp" />
|
||||||
<ClInclude Include="discord\discord.hpp" />
|
<ClInclude Include="discord\discord.hpp" />
|
||||||
<ClInclude Include="discord\http.hpp" />
|
<ClInclude Include="discord\http.hpp" />
|
||||||
|
<ClInclude Include="discord\objects.hpp" />
|
||||||
<ClInclude Include="discord\websocket.hpp" />
|
<ClInclude Include="discord\websocket.hpp" />
|
||||||
<ClInclude Include="settings.hpp" />
|
<ClInclude Include="settings.hpp" />
|
||||||
<ClInclude Include="windows\mainwindow.hpp" />
|
<ClInclude Include="windows\mainwindow.hpp" />
|
||||||
|
|||||||
@@ -48,6 +48,9 @@
|
|||||||
<ClCompile Include="components\chatmessage.cpp">
|
<ClCompile Include="components\chatmessage.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="discord\objects.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="windows\mainwindow.hpp">
|
<ClInclude Include="windows\mainwindow.hpp">
|
||||||
@@ -83,5 +86,8 @@
|
|||||||
<ClInclude Include="components\chatmessage.hpp">
|
<ClInclude Include="components\chatmessage.hpp">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="discord\objects.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -316,307 +316,3 @@ void DiscordClient::LoadEventMap() {
|
|||||||
m_event_map["READY"] = GatewayEvent::READY;
|
m_event_map["READY"] = GatewayEvent::READY;
|
||||||
m_event_map["MESSAGE_CREATE"] = GatewayEvent::MESSAGE_CREATE;
|
m_event_map["MESSAGE_CREATE"] = GatewayEvent::MESSAGE_CREATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define JS_D(k, t) \
|
|
||||||
do { \
|
|
||||||
j.at(k).get_to(t); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define JS_O(k, t) \
|
|
||||||
do { \
|
|
||||||
if (j.contains(k)) j.at(k).get_to(t); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define JS_N(k, t) \
|
|
||||||
do { \
|
|
||||||
if (!j.at(k).is_null()) j.at(k).get_to(t); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define JS_ON(k, t) \
|
|
||||||
do { \
|
|
||||||
if (j.contains(k) && !j.at(k).is_null()) \
|
|
||||||
j.at(k).get_to(t); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, GatewayMessage &m) {
|
|
||||||
JS_D("op", m.Opcode);
|
|
||||||
m.Data = j.at("d");
|
|
||||||
|
|
||||||
JS_ON("t", m.Type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, HelloMessageData &m) {
|
|
||||||
JS_D("heartbeat_interval", m.HeartbeatInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, UserData &m) {
|
|
||||||
JS_D("id", m.ID);
|
|
||||||
JS_D("username", m.Username);
|
|
||||||
JS_D("discriminator", m.Discriminator);
|
|
||||||
JS_N("avatar", m.Avatar);
|
|
||||||
JS_O("bot", m.IsBot);
|
|
||||||
JS_O("system", m.IsSystem);
|
|
||||||
JS_O("mfa_enabled", m.IsMFAEnabled);
|
|
||||||
JS_O("locale", m.Locale);
|
|
||||||
JS_O("verified", m.IsVerified);
|
|
||||||
JS_O("email", m.Email);
|
|
||||||
JS_O("flags", m.Flags);
|
|
||||||
JS_O("premium_type", m.PremiumType);
|
|
||||||
JS_O("public_flags", m.PublicFlags);
|
|
||||||
JS_O("desktop", m.IsDesktop);
|
|
||||||
JS_O("mobile", m.IsMobile);
|
|
||||||
JS_ON("nsfw_allowed", m.IsNSFWAllowed);
|
|
||||||
JS_ON("phone", m.Phone);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, GuildData &m) {
|
|
||||||
JS_D("id", m.ID);
|
|
||||||
if (j.contains("unavailable")) {
|
|
||||||
m.IsUnavailable = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_D("name", m.Name);
|
|
||||||
JS_N("icon", m.Icon);
|
|
||||||
JS_N("splash", m.Splash);
|
|
||||||
JS_N("discovery_splash", m.DiscoverySplash);
|
|
||||||
JS_O("owner", m.IsOwner);
|
|
||||||
JS_D("owner_id", m.OwnerID);
|
|
||||||
JS_O("permissions", m.Permissions);
|
|
||||||
JS_O("permissions_new", m.PermissionsNew);
|
|
||||||
JS_D("region", m.VoiceRegion);
|
|
||||||
JS_N("afk_channel_id", m.AFKChannelID);
|
|
||||||
JS_D("afk_timeout", m.AFKTimeout);
|
|
||||||
JS_O("embed_enabled", m.IsEmbedEnabled);
|
|
||||||
JS_ON("embed_channel_id", m.EmbedChannelID);
|
|
||||||
JS_D("verification_level", m.VerificationLevel);
|
|
||||||
JS_D("default_message_notifications", m.DefaultMessageNotifications);
|
|
||||||
JS_D("explicit_content_filter", m.ExplicitContentFilter);
|
|
||||||
// JS_D("roles", m.Roles);
|
|
||||||
// JS_D("emojis", m.Emojis);
|
|
||||||
JS_D("features", m.Features);
|
|
||||||
JS_D("mfa_level", m.MFALevel);
|
|
||||||
JS_N("application_id", m.ApplicationID);
|
|
||||||
JS_O("widget_enabled", m.IsWidgetEnabled);
|
|
||||||
JS_ON("widget_channel_id", m.WidgetChannelID);
|
|
||||||
JS_N("system_channel_id", m.SystemChannelID);
|
|
||||||
JS_D("system_channel_flags", m.SystemChannelFlags);
|
|
||||||
JS_N("rules_channel_id", m.RulesChannelID);
|
|
||||||
JS_O("joined_at", m.JoinedAt);
|
|
||||||
JS_O("large", m.IsLarge);
|
|
||||||
JS_O("unavailable", m.IsUnavailable);
|
|
||||||
JS_O("member_count", m.MemberCount);
|
|
||||||
// JS_O("voice_states", m.VoiceStates);
|
|
||||||
// JS_O("members", m.Members);
|
|
||||||
JS_O("channels", m.Channels);
|
|
||||||
// JS_O("presences", m.Presences);
|
|
||||||
JS_ON("max_presences", m.MaxPresences);
|
|
||||||
JS_O("max_members", m.MaxMembers);
|
|
||||||
JS_N("vanity_url_code", m.VanityURL);
|
|
||||||
JS_N("description", m.Description);
|
|
||||||
JS_N("banner", m.BannerHash);
|
|
||||||
JS_D("premium_tier", m.PremiumTier);
|
|
||||||
JS_O("premium_subscription_count", m.PremiumSubscriptionCount);
|
|
||||||
JS_D("preferred_locale", m.PreferredLocale);
|
|
||||||
JS_N("public_updates_channel_id", m.PublicUpdatesChannelID);
|
|
||||||
JS_O("max_video_channel_users", m.MaxVideoChannelUsers);
|
|
||||||
JS_O("approximate_member_count", m.ApproximateMemberCount);
|
|
||||||
JS_O("approximate_presence_count", m.ApproximatePresenceCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, ChannelData &m) {
|
|
||||||
JS_D("id", m.ID);
|
|
||||||
JS_D("type", m.Type);
|
|
||||||
JS_O("guild_id", m.GuildID);
|
|
||||||
JS_O("position", m.Position);
|
|
||||||
// JS_O("permission_overwrites", m.PermissionOverwrites);
|
|
||||||
JS_O("name", m.Name);
|
|
||||||
JS_ON("topic", m.Topic);
|
|
||||||
JS_O("nsfw", m.IsNSFW);
|
|
||||||
JS_ON("last_message_id", m.LastMessageID);
|
|
||||||
JS_O("bitrate", m.Bitrate);
|
|
||||||
JS_O("user_limit", m.UserLimit);
|
|
||||||
JS_O("rate_limit_per_user", m.RateLimitPerUser);
|
|
||||||
JS_O("recipients", m.Recipients);
|
|
||||||
JS_ON("icon", m.Icon);
|
|
||||||
JS_O("owner_id", m.OwnerID);
|
|
||||||
JS_O("application_id", m.ApplicationID);
|
|
||||||
JS_ON("parent_id", m.ParentID);
|
|
||||||
JS_ON("last_pin_timestamp", m.LastPinTimestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, MessageData &m) {
|
|
||||||
JS_D("id", m.ID);
|
|
||||||
JS_D("channel_id", m.ChannelID);
|
|
||||||
JS_O("guild_id", m.GuildID);
|
|
||||||
JS_D("author", m.Author);
|
|
||||||
// JS_O("member", m.Member);
|
|
||||||
JS_D("content", m.Content);
|
|
||||||
JS_D("timestamp", m.Timestamp);
|
|
||||||
JS_N("edited_timestamp", m.EditedTimestamp);
|
|
||||||
JS_D("tts", m.IsTTS);
|
|
||||||
JS_D("mention_everyone", m.DoesMentionEveryone);
|
|
||||||
JS_D("mentions", m.Mentions);
|
|
||||||
// JS_D("mention_roles", m.MentionRoles);
|
|
||||||
// JS_O("mention_channels", m.MentionChannels);
|
|
||||||
// JS_D("attachments", m.Attachments);
|
|
||||||
// JS_D("embeds", m.Embeds);
|
|
||||||
// JS_O("reactions", m.Reactions);
|
|
||||||
JS_O("nonce", m.Nonce);
|
|
||||||
JS_D("pinned", m.IsPinned);
|
|
||||||
JS_O("webhook_id", m.WebhookID);
|
|
||||||
JS_D("type", m.Type);
|
|
||||||
// JS_O("activity", m.Activity);
|
|
||||||
// JS_O("application", m.Application);
|
|
||||||
// JS_O("message_reference", m.MessageReference);
|
|
||||||
JS_O("flags", m.Flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, ReadyEventData &m) {
|
|
||||||
JS_D("v", m.GatewayVersion);
|
|
||||||
JS_D("user", m.User);
|
|
||||||
JS_D("guilds", m.Guilds);
|
|
||||||
JS_D("session_id", m.SessionID);
|
|
||||||
JS_D("analytics_token", m.AnalyticsToken);
|
|
||||||
JS_D("friend_suggestion_count", m.FriendSuggestionCount);
|
|
||||||
JS_D("user_settings", m.UserSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, UserSettingsData &m) {
|
|
||||||
JS_D("timezone_offset", m.TimezoneOffset);
|
|
||||||
JS_D("theme", m.Theme);
|
|
||||||
JS_D("stream_notifications_enabled", m.AreStreamNotificationsEnabled);
|
|
||||||
JS_D("status", m.Status);
|
|
||||||
JS_D("show_current_game", m.ShouldShowCurrentGame);
|
|
||||||
// JS_D("restricted_guilds", m.RestrictedGuilds);
|
|
||||||
JS_D("render_reactions", m.ShouldRenderReactions);
|
|
||||||
JS_D("render_embeds", m.ShouldRenderEmbeds);
|
|
||||||
JS_D("native_phone_integration_enabled", m.IsNativePhoneIntegrationEnabled);
|
|
||||||
JS_D("message_display_compact", m.ShouldMessageDisplayCompact);
|
|
||||||
JS_D("locale", m.Locale);
|
|
||||||
JS_D("inline_embed_media", m.ShouldInlineEmbedMedia);
|
|
||||||
JS_D("inline_attachment_media", m.ShouldInlineAttachmentMedia);
|
|
||||||
JS_D("guild_positions", m.GuildPositions);
|
|
||||||
// JS_D("guild_folders", m.GuildFolders);
|
|
||||||
JS_D("gif_auto_play", m.ShouldGIFAutoplay);
|
|
||||||
// JS_D("friend_source_flags", m.FriendSourceFlags);
|
|
||||||
JS_D("explicit_content_filter", m.ExplicitContentFilter);
|
|
||||||
JS_D("enable_tts_command", m.IsTTSCommandEnabled);
|
|
||||||
JS_D("disable_games_tab", m.ShouldDisableGamesTab);
|
|
||||||
JS_D("developer_mode", m.DeveloperMode);
|
|
||||||
JS_D("detect_platform_accounts", m.ShouldDetectPlatformAccounts);
|
|
||||||
JS_D("default_guilds_restricted", m.AreDefaultGuildsRestricted);
|
|
||||||
// JS_N("custom_status", m.CustomStatus);
|
|
||||||
JS_D("convert_emoticons", m.ShouldConvertEmoticons);
|
|
||||||
JS_D("contact_sync_enabled", m.IsContactSyncEnabled);
|
|
||||||
JS_D("animate_emoji", m.ShouldAnimateEmojis);
|
|
||||||
JS_D("allow_accessibility_detection", m.IsAccessibilityDetectionAllowed);
|
|
||||||
JS_D("afk_timeout", m.AFKTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, EmbedFooterData &m) {
|
|
||||||
JS_D("text", m.Text);
|
|
||||||
JS_O("icon_url", m.IconURL);
|
|
||||||
JS_O("proxy_icon_url", m.ProxyIconURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, EmbedImageData &m) {
|
|
||||||
JS_O("url", m.URL);
|
|
||||||
JS_O("proxy_url", m.ProxyURL);
|
|
||||||
JS_O("height", m.Height);
|
|
||||||
JS_O("width", m.Width);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, EmbedThumbnailData &m) {
|
|
||||||
JS_O("url", m.URL);
|
|
||||||
JS_O("proxy_url", m.ProxyURL);
|
|
||||||
JS_O("height", m.Height);
|
|
||||||
JS_O("width", m.Width);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, EmbedVideoData &m) {
|
|
||||||
JS_O("url", m.URL);
|
|
||||||
JS_O("height", m.Height);
|
|
||||||
JS_O("width", m.Width);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, EmbedProviderData &m) {
|
|
||||||
JS_O("name", m.Name);
|
|
||||||
JS_O("url", m.URL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, EmbedAuthorData &m) {
|
|
||||||
JS_O("name", m.Name);
|
|
||||||
JS_O("url", m.URL);
|
|
||||||
JS_O("icon_url", m.IconURL);
|
|
||||||
JS_O("proxy_icon_url", m.ProxyIconURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, EmbedFieldData &m) {
|
|
||||||
JS_D("name", m.Name);
|
|
||||||
JS_D("value", m.Value);
|
|
||||||
JS_O("inline", m.Inline);
|
|
||||||
}
|
|
||||||
|
|
||||||
void to_json(nlohmann::json &j, const IdentifyProperties &m) {
|
|
||||||
j["$os"] = m.OS;
|
|
||||||
j["$browser"] = m.Browser;
|
|
||||||
j["$device"] = m.Device;
|
|
||||||
}
|
|
||||||
|
|
||||||
void to_json(nlohmann::json &j, const IdentifyMessage &m) {
|
|
||||||
j["op"] = GatewayOp::Identify;
|
|
||||||
j["d"] = nlohmann::json::object();
|
|
||||||
j["d"]["token"] = m.Token;
|
|
||||||
j["d"]["properties"] = m.Properties;
|
|
||||||
|
|
||||||
if (m.LargeThreshold)
|
|
||||||
j["d"]["large_threshold"] = m.LargeThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
void to_json(nlohmann::json &j, const HeartbeatMessage &m) {
|
|
||||||
j["op"] = GatewayOp::Heartbeat;
|
|
||||||
if (m.Sequence == -1)
|
|
||||||
j["d"] = nullptr;
|
|
||||||
else
|
|
||||||
j["d"] = m.Sequence;
|
|
||||||
}
|
|
||||||
|
|
||||||
void to_json(nlohmann::json &j, const CreateMessageObject &m) {
|
|
||||||
j["content"] = m.Content;
|
|
||||||
}
|
|
||||||
|
|
||||||
Snowflake::Snowflake()
|
|
||||||
: m_num(Invalid) {}
|
|
||||||
|
|
||||||
Snowflake::Snowflake(const Snowflake &s)
|
|
||||||
: m_num(s.m_num) {}
|
|
||||||
|
|
||||||
Snowflake::Snowflake(uint64_t n)
|
|
||||||
: m_num(n) {}
|
|
||||||
|
|
||||||
Snowflake::Snowflake(const std::string &str) {
|
|
||||||
if (str.size())
|
|
||||||
m_num = std::stoull(str);
|
|
||||||
else
|
|
||||||
m_num = Invalid;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool Snowflake::IsValid() const {
|
|
||||||
return m_num != Invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, Snowflake &s) {
|
|
||||||
std::string tmp;
|
|
||||||
j.get_to(tmp);
|
|
||||||
s.m_num = std::stoull(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void to_json(nlohmann::json &j, const Snowflake &s) {
|
|
||||||
j = std::to_string(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef JS_O
|
|
||||||
#undef JS_D
|
|
||||||
#undef JS_N
|
|
||||||
#undef JS_ON
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "websocket.hpp"
|
#include "websocket.hpp"
|
||||||
#include "http.hpp"
|
#include "http.hpp"
|
||||||
|
#include "objects.hpp"
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@@ -16,416 +17,6 @@
|
|||||||
#undef GetMessage
|
#undef GetMessage
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Snowflake {
|
|
||||||
Snowflake();
|
|
||||||
Snowflake(const Snowflake &s);
|
|
||||||
Snowflake(uint64_t n);
|
|
||||||
Snowflake(const std::string &str);
|
|
||||||
|
|
||||||
bool IsValid() const;
|
|
||||||
|
|
||||||
bool operator==(const Snowflake &s) const noexcept {
|
|
||||||
return m_num == s.m_num;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator<(const Snowflake &s) const noexcept {
|
|
||||||
return m_num < s.m_num;
|
|
||||||
}
|
|
||||||
|
|
||||||
operator uint64_t() const noexcept {
|
|
||||||
return m_num;
|
|
||||||
}
|
|
||||||
|
|
||||||
const static int Invalid = -1;
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, Snowflake &s);
|
|
||||||
friend void to_json(nlohmann::json &j, const Snowflake &s);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend struct std::hash<Snowflake>;
|
|
||||||
friend struct std::less<Snowflake>;
|
|
||||||
unsigned long long m_num;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace std {
|
|
||||||
template<>
|
|
||||||
struct hash<Snowflake> {
|
|
||||||
std::size_t operator()(const Snowflake &k) const {
|
|
||||||
return k.m_num;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct less<Snowflake> {
|
|
||||||
bool operator()(const Snowflake &l, const Snowflake &r) const {
|
|
||||||
return l.m_num < r.m_num;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
enum class GatewayOp : int {
|
|
||||||
Event = 0,
|
|
||||||
Heartbeat = 1,
|
|
||||||
Identify = 2,
|
|
||||||
Hello = 10,
|
|
||||||
HeartbeatAck = 11,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class GatewayEvent : int {
|
|
||||||
READY,
|
|
||||||
MESSAGE_CREATE,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GatewayMessage {
|
|
||||||
GatewayOp Opcode;
|
|
||||||
nlohmann::json Data;
|
|
||||||
std::string Type;
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, GatewayMessage &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HelloMessageData {
|
|
||||||
int HeartbeatInterval;
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, HelloMessageData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class ChannelType : int {
|
|
||||||
GUILD_TEXT = 0,
|
|
||||||
DM = 1,
|
|
||||||
GUILD_VOICE = 2,
|
|
||||||
GROUP_DM = 3,
|
|
||||||
GUILD_CATEGORY = 4,
|
|
||||||
GUILD_NEWS = 5,
|
|
||||||
GUILD_STORE = 6,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UserData {
|
|
||||||
Snowflake ID; //
|
|
||||||
std::string Username; //
|
|
||||||
std::string Discriminator; //
|
|
||||||
std::string Avatar; // null
|
|
||||||
bool IsBot = false; // opt
|
|
||||||
bool IsSystem = false; // opt
|
|
||||||
bool IsMFAEnabled = false; // opt
|
|
||||||
std::string Locale; // opt
|
|
||||||
bool IsVerified = false; // opt
|
|
||||||
std::string Email; // opt, null
|
|
||||||
int Flags = 0; // opt
|
|
||||||
int PremiumType = 0; // opt
|
|
||||||
int PublicFlags = 0; // opt
|
|
||||||
|
|
||||||
// undocumented (opt)
|
|
||||||
bool IsDesktop = false; //
|
|
||||||
bool IsMobile = false; //
|
|
||||||
bool IsNSFWAllowed = false; // null
|
|
||||||
std::string Phone; // null?
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, UserData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ChannelData {
|
|
||||||
Snowflake ID; //
|
|
||||||
ChannelType Type; //
|
|
||||||
Snowflake GuildID; // opt
|
|
||||||
int Position = -1; // opt
|
|
||||||
// std::vector<PermissionOverwriteData> PermissionOverwrites; // opt
|
|
||||||
std::string Name; // opt
|
|
||||||
std::string Topic; // opt, null
|
|
||||||
bool IsNSFW = false; // opt
|
|
||||||
Snowflake LastMessageID; // opt, null
|
|
||||||
int Bitrate = 0; // opt
|
|
||||||
int UserLimit = 0; // opt
|
|
||||||
int RateLimitPerUser = 0; // opt
|
|
||||||
std::vector<UserData> Recipients; // opt
|
|
||||||
std::string Icon; // opt, null
|
|
||||||
Snowflake OwnerID; // opt
|
|
||||||
Snowflake ApplicationID; // opt
|
|
||||||
Snowflake ParentID; // opt, null
|
|
||||||
std::string LastPinTimestamp; // opt, can be null even tho docs say otherwise
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, ChannelData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
// a bot is apparently only supposed to receive the `id` and `unavailable` as false
|
|
||||||
// but user tokens seem to get the full objects (minus users)
|
|
||||||
struct GuildData {
|
|
||||||
Snowflake ID; //
|
|
||||||
std::string Name; //
|
|
||||||
std::string Icon; // null
|
|
||||||
std::string Splash; // null
|
|
||||||
std::string DiscoverySplash; // null
|
|
||||||
bool IsOwner = false; // opt
|
|
||||||
Snowflake OwnerID; //
|
|
||||||
int Permissions = 0; // opt
|
|
||||||
std::string PermissionsNew; // opt
|
|
||||||
std::string VoiceRegion; // opt
|
|
||||||
Snowflake AFKChannelID; // null
|
|
||||||
int AFKTimeout; //
|
|
||||||
bool IsEmbedEnabled = false; // opt, deprecated
|
|
||||||
Snowflake EmbedChannelID; // opt, null, deprecated
|
|
||||||
int VerificationLevel; //
|
|
||||||
int DefaultMessageNotifications; //
|
|
||||||
int ExplicitContentFilter; //
|
|
||||||
// std::vector<RoleData> Roles; //
|
|
||||||
// std::vector<EmojiData> Emojis; //
|
|
||||||
std::vector<std::string> Features; //
|
|
||||||
int MFALevel; //
|
|
||||||
Snowflake ApplicationID; // null
|
|
||||||
bool IsWidgetEnabled = false; // opt
|
|
||||||
Snowflake WidgetChannelID; // opt, null
|
|
||||||
Snowflake SystemChannelID; // null
|
|
||||||
int SystemChannelFlags; //
|
|
||||||
Snowflake RulesChannelID; // null
|
|
||||||
std::string JoinedAt; // opt*
|
|
||||||
bool IsLarge = false; // opt*
|
|
||||||
bool IsUnavailable = false; // opt*
|
|
||||||
int MemberCount = 0; // opt*
|
|
||||||
// std::vector<VoiceStateData> VoiceStates; // opt*
|
|
||||||
// std::vector<MemberData> Members; // opt* - incomplete anyways
|
|
||||||
std::vector<ChannelData> Channels; // opt*
|
|
||||||
// std::vector<PresenceUpdateData> Presences; // opt*
|
|
||||||
int MaxPresences = 0; // opt, null
|
|
||||||
int MaxMembers = 0; // opt
|
|
||||||
std::string VanityURL; // null
|
|
||||||
std::string Description; // null
|
|
||||||
std::string BannerHash; // null
|
|
||||||
int PremiumTier; //
|
|
||||||
int PremiumSubscriptionCount = 0; // opt
|
|
||||||
std::string PreferredLocale; //
|
|
||||||
Snowflake PublicUpdatesChannelID; // null
|
|
||||||
int MaxVideoChannelUsers = 0; // opt
|
|
||||||
int ApproximateMemberCount = 0; // opt
|
|
||||||
int ApproximatePresenceCount = 0; // opt
|
|
||||||
|
|
||||||
// undocumented
|
|
||||||
// std::map<std::string, Unknown> GuildHashes;
|
|
||||||
bool IsLazy = false;
|
|
||||||
|
|
||||||
// * - documentation says only sent in GUILD_CREATE, but these can be sent anyways in the READY event
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, GuildData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UserSettingsData {
|
|
||||||
int TimezoneOffset; //
|
|
||||||
std::string Theme; //
|
|
||||||
bool AreStreamNotificationsEnabled; //
|
|
||||||
std::string Status; //
|
|
||||||
bool ShouldShowCurrentGame; //
|
|
||||||
// std::vector<Unknown> RestrictedGuilds; //
|
|
||||||
bool ShouldRenderReactions; //
|
|
||||||
bool ShouldRenderEmbeds; //
|
|
||||||
bool IsNativePhoneIntegrationEnabled; //
|
|
||||||
bool ShouldMessageDisplayCompact; //
|
|
||||||
std::string Locale; //
|
|
||||||
bool ShouldInlineEmbedMedia; //
|
|
||||||
bool ShouldInlineAttachmentMedia; //
|
|
||||||
std::vector<Snowflake> GuildPositions; //
|
|
||||||
// std::vector<GuildFolderEntryData> GuildFolders; //
|
|
||||||
bool ShouldGIFAutoplay; //
|
|
||||||
// Unknown FriendSourceFlags; //
|
|
||||||
int ExplicitContentFilter; //
|
|
||||||
bool IsTTSCommandEnabled; //
|
|
||||||
bool ShouldDisableGamesTab; //
|
|
||||||
bool DeveloperMode; //
|
|
||||||
bool ShouldDetectPlatformAccounts; //
|
|
||||||
bool AreDefaultGuildsRestricted; //
|
|
||||||
// Unknown CustomStatus; // null
|
|
||||||
bool ShouldConvertEmoticons; //
|
|
||||||
bool IsContactSyncEnabled; //
|
|
||||||
bool ShouldAnimateEmojis; //
|
|
||||||
bool IsAccessibilityDetectionAllowed; //
|
|
||||||
int AFKTimeout;
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, UserSettingsData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class MessageType {
|
|
||||||
DEFAULT = 0,
|
|
||||||
RECIPIENT_ADD = 1,
|
|
||||||
RECIPIENT_REMOVE = 2,
|
|
||||||
CALL = 3,
|
|
||||||
CHANNEL_NaME_CHANGE = 4,
|
|
||||||
CHANNEL_ICON_CHANGE = 5,
|
|
||||||
CHANNEL_PINNED_MESSAGE = 6,
|
|
||||||
GUILD_MEMBER_JOIN = 6,
|
|
||||||
USER_PREMIUM_GUILD_SUBSCRIPTION = 7,
|
|
||||||
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = 8,
|
|
||||||
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 9,
|
|
||||||
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 10,
|
|
||||||
CHANNEL_FOLLOW_ADD = 12,
|
|
||||||
GUILD_DISCOVERY_DISQUALIFIED = 13,
|
|
||||||
GUILD_DISCOVERY_REQUALIFIED = 14,
|
|
||||||
};
|
|
||||||
|
|
||||||
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::string IconURL; // opt
|
|
||||||
std::string ProxyIconURL; // opt
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, EmbedFooterData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EmbedImageData {
|
|
||||||
std::string URL; // opt
|
|
||||||
std::string ProxyURL; // opt
|
|
||||||
int Height = 0; // opt
|
|
||||||
int Width = 0; // opt
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, EmbedImageData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EmbedThumbnailData {
|
|
||||||
std::string URL; // opt
|
|
||||||
std::string ProxyURL; // opt
|
|
||||||
int Height = 0; // opt
|
|
||||||
int Width = 0; // opt
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, EmbedThumbnailData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EmbedVideoData {
|
|
||||||
std::string URL; // opt
|
|
||||||
int Height = 0; // opt
|
|
||||||
int Width = 0; // opt
|
|
||||||
friend void from_json(const nlohmann::json &j, EmbedVideoData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EmbedProviderData {
|
|
||||||
std::string Name; // opt
|
|
||||||
std::string URL; // opt
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, EmbedProviderData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EmbedAuthorData {
|
|
||||||
std::string Name; // opt
|
|
||||||
std::string URL; // opt
|
|
||||||
std::string IconURL; // opt
|
|
||||||
std::string ProxyIconURL; // opt
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, EmbedAuthorData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EmbedFieldData {
|
|
||||||
std::string Name; //
|
|
||||||
std::string Value; //
|
|
||||||
bool Inline = false; // opt
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, EmbedFieldData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EmbedData {
|
|
||||||
std::string Title; // opt
|
|
||||||
std::string Type; // opt
|
|
||||||
std::string Description; // opt
|
|
||||||
std::string URL; // opt
|
|
||||||
std::string Timestamp; // opt
|
|
||||||
int Color = 0; // opt
|
|
||||||
EmbedFooterData Footer; // opt
|
|
||||||
EmbedImageData Image; // opt
|
|
||||||
EmbedThumbnailData Thumbnail; // opt
|
|
||||||
EmbedVideoData Video; // opt
|
|
||||||
EmbedProviderData Provider; // opt
|
|
||||||
EmbedAuthorData Author; // opt
|
|
||||||
std::vector<EmbedFieldData> Fields; // opt
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, EmbedData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MessageData {
|
|
||||||
Snowflake ID; //
|
|
||||||
Snowflake ChannelID; //
|
|
||||||
Snowflake GuildID; // opt
|
|
||||||
UserData Author; //
|
|
||||||
// GuildMemberData Member; // opt
|
|
||||||
std::string Content; //
|
|
||||||
std::string Timestamp; //
|
|
||||||
std::string EditedTimestamp; // null
|
|
||||||
bool IsTTS; //
|
|
||||||
bool DoesMentionEveryone; //
|
|
||||||
std::vector<UserData> Mentions; //
|
|
||||||
// std::vector<RoleData> 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
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, MessageData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ReadyEventData {
|
|
||||||
int GatewayVersion; //
|
|
||||||
UserData User; //
|
|
||||||
std::vector<GuildData> Guilds; //
|
|
||||||
std::string SessionID; //
|
|
||||||
// std::vector<ChannelData?/PrivateChannelData?> PrivateChannels;
|
|
||||||
|
|
||||||
// undocumented
|
|
||||||
std::string AnalyticsToken; // opt
|
|
||||||
int FriendSuggestionCount; // opt
|
|
||||||
UserSettingsData UserSettings; // opt
|
|
||||||
// std::vector<Unknown> ConnectedAccounts; // opt
|
|
||||||
// std::map<std::string, Unknown> Consents; // opt
|
|
||||||
// std::vector<Unknown> Experiments; // opt
|
|
||||||
// std::vector<Unknown> GuildExperiments; // opt
|
|
||||||
// std::map<Unknown, Unknown> Notes; // opt
|
|
||||||
// std::vector<PresenceData> Presences; // opt
|
|
||||||
// std::vector<ReadStateData> ReadStates; // opt
|
|
||||||
// std::vector<RelationshipData> Relationships; // opt
|
|
||||||
// Unknown Tutorial; // opt, null
|
|
||||||
// std::vector<GuildSettingData> UserGuildSettings; // opt
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, ReadyEventData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IdentifyProperties {
|
|
||||||
std::string OS;
|
|
||||||
std::string Browser;
|
|
||||||
std::string Device;
|
|
||||||
|
|
||||||
friend void to_json(nlohmann::json &j, const IdentifyProperties &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IdentifyMessage : GatewayMessage {
|
|
||||||
std::string Token;
|
|
||||||
IdentifyProperties Properties;
|
|
||||||
bool DoesSupportCompression = false;
|
|
||||||
int LargeThreshold = 0;
|
|
||||||
|
|
||||||
friend void to_json(nlohmann::json &j, const IdentifyMessage &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HeartbeatMessage : GatewayMessage {
|
|
||||||
int Sequence;
|
|
||||||
|
|
||||||
friend void to_json(nlohmann::json &j, const HeartbeatMessage &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CreateMessageObject {
|
|
||||||
std::string Content;
|
|
||||||
|
|
||||||
friend void to_json(nlohmann::json &j, const CreateMessageObject &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/29775153/stopping-long-sleep-threads/29775639#29775639
|
// https://stackoverflow.com/questions/29775153/stopping-long-sleep-threads/29775639#29775639
|
||||||
class HeartbeatWaiter {
|
class HeartbeatWaiter {
|
||||||
public:
|
public:
|
||||||
|
|||||||
305
discord/objects.cpp
Normal file
305
discord/objects.cpp
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
#include "objects.hpp"
|
||||||
|
|
||||||
|
#define JS_D(k, t) \
|
||||||
|
do { \
|
||||||
|
j.at(k).get_to(t); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define JS_O(k, t) \
|
||||||
|
do { \
|
||||||
|
if (j.contains(k)) j.at(k).get_to(t); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define JS_N(k, t) \
|
||||||
|
do { \
|
||||||
|
if (!j.at(k).is_null()) j.at(k).get_to(t); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define JS_ON(k, t) \
|
||||||
|
do { \
|
||||||
|
if (j.contains(k) && !j.at(k).is_null()) \
|
||||||
|
j.at(k).get_to(t); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, GatewayMessage &m) {
|
||||||
|
JS_D("op", m.Opcode);
|
||||||
|
m.Data = j.at("d");
|
||||||
|
|
||||||
|
JS_ON("t", m.Type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, HelloMessageData &m) {
|
||||||
|
JS_D("heartbeat_interval", m.HeartbeatInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, UserData &m) {
|
||||||
|
JS_D("id", m.ID);
|
||||||
|
JS_D("username", m.Username);
|
||||||
|
JS_D("discriminator", m.Discriminator);
|
||||||
|
JS_N("avatar", m.Avatar);
|
||||||
|
JS_O("bot", m.IsBot);
|
||||||
|
JS_O("system", m.IsSystem);
|
||||||
|
JS_O("mfa_enabled", m.IsMFAEnabled);
|
||||||
|
JS_O("locale", m.Locale);
|
||||||
|
JS_O("verified", m.IsVerified);
|
||||||
|
JS_O("email", m.Email);
|
||||||
|
JS_O("flags", m.Flags);
|
||||||
|
JS_O("premium_type", m.PremiumType);
|
||||||
|
JS_O("public_flags", m.PublicFlags);
|
||||||
|
JS_O("desktop", m.IsDesktop);
|
||||||
|
JS_O("mobile", m.IsMobile);
|
||||||
|
JS_ON("nsfw_allowed", m.IsNSFWAllowed);
|
||||||
|
JS_ON("phone", m.Phone);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, GuildData &m) {
|
||||||
|
JS_D("id", m.ID);
|
||||||
|
if (j.contains("unavailable")) {
|
||||||
|
m.IsUnavailable = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JS_D("name", m.Name);
|
||||||
|
JS_N("icon", m.Icon);
|
||||||
|
JS_N("splash", m.Splash);
|
||||||
|
JS_N("discovery_splash", m.DiscoverySplash);
|
||||||
|
JS_O("owner", m.IsOwner);
|
||||||
|
JS_D("owner_id", m.OwnerID);
|
||||||
|
JS_O("permissions", m.Permissions);
|
||||||
|
JS_O("permissions_new", m.PermissionsNew);
|
||||||
|
JS_D("region", m.VoiceRegion);
|
||||||
|
JS_N("afk_channel_id", m.AFKChannelID);
|
||||||
|
JS_D("afk_timeout", m.AFKTimeout);
|
||||||
|
JS_O("embed_enabled", m.IsEmbedEnabled);
|
||||||
|
JS_ON("embed_channel_id", m.EmbedChannelID);
|
||||||
|
JS_D("verification_level", m.VerificationLevel);
|
||||||
|
JS_D("default_message_notifications", m.DefaultMessageNotifications);
|
||||||
|
JS_D("explicit_content_filter", m.ExplicitContentFilter);
|
||||||
|
// JS_D("roles", m.Roles);
|
||||||
|
// JS_D("emojis", m.Emojis);
|
||||||
|
JS_D("features", m.Features);
|
||||||
|
JS_D("mfa_level", m.MFALevel);
|
||||||
|
JS_N("application_id", m.ApplicationID);
|
||||||
|
JS_O("widget_enabled", m.IsWidgetEnabled);
|
||||||
|
JS_ON("widget_channel_id", m.WidgetChannelID);
|
||||||
|
JS_N("system_channel_id", m.SystemChannelID);
|
||||||
|
JS_D("system_channel_flags", m.SystemChannelFlags);
|
||||||
|
JS_N("rules_channel_id", m.RulesChannelID);
|
||||||
|
JS_O("joined_at", m.JoinedAt);
|
||||||
|
JS_O("large", m.IsLarge);
|
||||||
|
JS_O("unavailable", m.IsUnavailable);
|
||||||
|
JS_O("member_count", m.MemberCount);
|
||||||
|
// JS_O("voice_states", m.VoiceStates);
|
||||||
|
// JS_O("members", m.Members);
|
||||||
|
JS_O("channels", m.Channels);
|
||||||
|
// JS_O("presences", m.Presences);
|
||||||
|
JS_ON("max_presences", m.MaxPresences);
|
||||||
|
JS_O("max_members", m.MaxMembers);
|
||||||
|
JS_N("vanity_url_code", m.VanityURL);
|
||||||
|
JS_N("description", m.Description);
|
||||||
|
JS_N("banner", m.BannerHash);
|
||||||
|
JS_D("premium_tier", m.PremiumTier);
|
||||||
|
JS_O("premium_subscription_count", m.PremiumSubscriptionCount);
|
||||||
|
JS_D("preferred_locale", m.PreferredLocale);
|
||||||
|
JS_N("public_updates_channel_id", m.PublicUpdatesChannelID);
|
||||||
|
JS_O("max_video_channel_users", m.MaxVideoChannelUsers);
|
||||||
|
JS_O("approximate_member_count", m.ApproximateMemberCount);
|
||||||
|
JS_O("approximate_presence_count", m.ApproximatePresenceCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, ChannelData &m) {
|
||||||
|
JS_D("id", m.ID);
|
||||||
|
JS_D("type", m.Type);
|
||||||
|
JS_O("guild_id", m.GuildID);
|
||||||
|
JS_O("position", m.Position);
|
||||||
|
// JS_O("permission_overwrites", m.PermissionOverwrites);
|
||||||
|
JS_O("name", m.Name);
|
||||||
|
JS_ON("topic", m.Topic);
|
||||||
|
JS_O("nsfw", m.IsNSFW);
|
||||||
|
JS_ON("last_message_id", m.LastMessageID);
|
||||||
|
JS_O("bitrate", m.Bitrate);
|
||||||
|
JS_O("user_limit", m.UserLimit);
|
||||||
|
JS_O("rate_limit_per_user", m.RateLimitPerUser);
|
||||||
|
JS_O("recipients", m.Recipients);
|
||||||
|
JS_ON("icon", m.Icon);
|
||||||
|
JS_O("owner_id", m.OwnerID);
|
||||||
|
JS_O("application_id", m.ApplicationID);
|
||||||
|
JS_ON("parent_id", m.ParentID);
|
||||||
|
JS_ON("last_pin_timestamp", m.LastPinTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, MessageData &m) {
|
||||||
|
JS_D("id", m.ID);
|
||||||
|
JS_D("channel_id", m.ChannelID);
|
||||||
|
JS_O("guild_id", m.GuildID);
|
||||||
|
JS_D("author", m.Author);
|
||||||
|
// JS_O("member", m.Member);
|
||||||
|
JS_D("content", m.Content);
|
||||||
|
JS_D("timestamp", m.Timestamp);
|
||||||
|
JS_N("edited_timestamp", m.EditedTimestamp);
|
||||||
|
JS_D("tts", m.IsTTS);
|
||||||
|
JS_D("mention_everyone", m.DoesMentionEveryone);
|
||||||
|
JS_D("mentions", m.Mentions);
|
||||||
|
// JS_D("mention_roles", m.MentionRoles);
|
||||||
|
// JS_O("mention_channels", m.MentionChannels);
|
||||||
|
// JS_D("attachments", m.Attachments);
|
||||||
|
// JS_D("embeds", m.Embeds);
|
||||||
|
// JS_O("reactions", m.Reactions);
|
||||||
|
JS_O("nonce", m.Nonce);
|
||||||
|
JS_D("pinned", m.IsPinned);
|
||||||
|
JS_O("webhook_id", m.WebhookID);
|
||||||
|
JS_D("type", m.Type);
|
||||||
|
// JS_O("activity", m.Activity);
|
||||||
|
// JS_O("application", m.Application);
|
||||||
|
// JS_O("message_reference", m.MessageReference);
|
||||||
|
JS_O("flags", m.Flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, ReadyEventData &m) {
|
||||||
|
JS_D("v", m.GatewayVersion);
|
||||||
|
JS_D("user", m.User);
|
||||||
|
JS_D("guilds", m.Guilds);
|
||||||
|
JS_D("session_id", m.SessionID);
|
||||||
|
JS_D("analytics_token", m.AnalyticsToken);
|
||||||
|
JS_D("friend_suggestion_count", m.FriendSuggestionCount);
|
||||||
|
JS_D("user_settings", m.UserSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, UserSettingsData &m) {
|
||||||
|
JS_D("timezone_offset", m.TimezoneOffset);
|
||||||
|
JS_D("theme", m.Theme);
|
||||||
|
JS_D("stream_notifications_enabled", m.AreStreamNotificationsEnabled);
|
||||||
|
JS_D("status", m.Status);
|
||||||
|
JS_D("show_current_game", m.ShouldShowCurrentGame);
|
||||||
|
// JS_D("restricted_guilds", m.RestrictedGuilds);
|
||||||
|
JS_D("render_reactions", m.ShouldRenderReactions);
|
||||||
|
JS_D("render_embeds", m.ShouldRenderEmbeds);
|
||||||
|
JS_D("native_phone_integration_enabled", m.IsNativePhoneIntegrationEnabled);
|
||||||
|
JS_D("message_display_compact", m.ShouldMessageDisplayCompact);
|
||||||
|
JS_D("locale", m.Locale);
|
||||||
|
JS_D("inline_embed_media", m.ShouldInlineEmbedMedia);
|
||||||
|
JS_D("inline_attachment_media", m.ShouldInlineAttachmentMedia);
|
||||||
|
JS_D("guild_positions", m.GuildPositions);
|
||||||
|
// JS_D("guild_folders", m.GuildFolders);
|
||||||
|
JS_D("gif_auto_play", m.ShouldGIFAutoplay);
|
||||||
|
// JS_D("friend_source_flags", m.FriendSourceFlags);
|
||||||
|
JS_D("explicit_content_filter", m.ExplicitContentFilter);
|
||||||
|
JS_D("enable_tts_command", m.IsTTSCommandEnabled);
|
||||||
|
JS_D("disable_games_tab", m.ShouldDisableGamesTab);
|
||||||
|
JS_D("developer_mode", m.DeveloperMode);
|
||||||
|
JS_D("detect_platform_accounts", m.ShouldDetectPlatformAccounts);
|
||||||
|
JS_D("default_guilds_restricted", m.AreDefaultGuildsRestricted);
|
||||||
|
// JS_N("custom_status", m.CustomStatus);
|
||||||
|
JS_D("convert_emoticons", m.ShouldConvertEmoticons);
|
||||||
|
JS_D("contact_sync_enabled", m.IsContactSyncEnabled);
|
||||||
|
JS_D("animate_emoji", m.ShouldAnimateEmojis);
|
||||||
|
JS_D("allow_accessibility_detection", m.IsAccessibilityDetectionAllowed);
|
||||||
|
JS_D("afk_timeout", m.AFKTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, EmbedFooterData &m) {
|
||||||
|
JS_D("text", m.Text);
|
||||||
|
JS_O("icon_url", m.IconURL);
|
||||||
|
JS_O("proxy_icon_url", m.ProxyIconURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, EmbedImageData &m) {
|
||||||
|
JS_O("url", m.URL);
|
||||||
|
JS_O("proxy_url", m.ProxyURL);
|
||||||
|
JS_O("height", m.Height);
|
||||||
|
JS_O("width", m.Width);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, EmbedThumbnailData &m) {
|
||||||
|
JS_O("url", m.URL);
|
||||||
|
JS_O("proxy_url", m.ProxyURL);
|
||||||
|
JS_O("height", m.Height);
|
||||||
|
JS_O("width", m.Width);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, EmbedVideoData &m) {
|
||||||
|
JS_O("url", m.URL);
|
||||||
|
JS_O("height", m.Height);
|
||||||
|
JS_O("width", m.Width);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, EmbedProviderData &m) {
|
||||||
|
JS_O("name", m.Name);
|
||||||
|
JS_O("url", m.URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, EmbedAuthorData &m) {
|
||||||
|
JS_O("name", m.Name);
|
||||||
|
JS_O("url", m.URL);
|
||||||
|
JS_O("icon_url", m.IconURL);
|
||||||
|
JS_O("proxy_icon_url", m.ProxyIconURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, EmbedFieldData &m) {
|
||||||
|
JS_D("name", m.Name);
|
||||||
|
JS_D("value", m.Value);
|
||||||
|
JS_O("inline", m.Inline);
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(nlohmann::json &j, const IdentifyProperties &m) {
|
||||||
|
j["$os"] = m.OS;
|
||||||
|
j["$browser"] = m.Browser;
|
||||||
|
j["$device"] = m.Device;
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(nlohmann::json &j, const IdentifyMessage &m) {
|
||||||
|
j["op"] = GatewayOp::Identify;
|
||||||
|
j["d"] = nlohmann::json::object();
|
||||||
|
j["d"]["token"] = m.Token;
|
||||||
|
j["d"]["properties"] = m.Properties;
|
||||||
|
|
||||||
|
if (m.LargeThreshold)
|
||||||
|
j["d"]["large_threshold"] = m.LargeThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(nlohmann::json &j, const HeartbeatMessage &m) {
|
||||||
|
j["op"] = GatewayOp::Heartbeat;
|
||||||
|
if (m.Sequence == -1)
|
||||||
|
j["d"] = nullptr;
|
||||||
|
else
|
||||||
|
j["d"] = m.Sequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(nlohmann::json &j, const CreateMessageObject &m) {
|
||||||
|
j["content"] = m.Content;
|
||||||
|
}
|
||||||
|
|
||||||
|
Snowflake::Snowflake()
|
||||||
|
: m_num(Invalid) {}
|
||||||
|
|
||||||
|
Snowflake::Snowflake(const Snowflake &s)
|
||||||
|
: m_num(s.m_num) {}
|
||||||
|
|
||||||
|
Snowflake::Snowflake(uint64_t n)
|
||||||
|
: m_num(n) {}
|
||||||
|
|
||||||
|
Snowflake::Snowflake(const std::string &str) {
|
||||||
|
if (str.size())
|
||||||
|
m_num = std::stoull(str);
|
||||||
|
else
|
||||||
|
m_num = Invalid;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool Snowflake::IsValid() const {
|
||||||
|
return m_num != Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, Snowflake &s) {
|
||||||
|
std::string tmp;
|
||||||
|
j.get_to(tmp);
|
||||||
|
s.m_num = std::stoull(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(nlohmann::json &j, const Snowflake &s) {
|
||||||
|
j = std::to_string(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef JS_O
|
||||||
|
#undef JS_D
|
||||||
|
#undef JS_N
|
||||||
|
#undef JS_ON
|
||||||
415
discord/objects.hpp
Normal file
415
discord/objects.hpp
Normal file
@@ -0,0 +1,415 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <algorithm>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
struct Snowflake {
|
||||||
|
Snowflake();
|
||||||
|
Snowflake(const Snowflake &s);
|
||||||
|
Snowflake(uint64_t n);
|
||||||
|
Snowflake(const std::string &str);
|
||||||
|
|
||||||
|
bool IsValid() const;
|
||||||
|
|
||||||
|
bool operator==(const Snowflake &s) const noexcept {
|
||||||
|
return m_num == s.m_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<(const Snowflake &s) const noexcept {
|
||||||
|
return m_num < s.m_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
operator uint64_t() const noexcept {
|
||||||
|
return m_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
const static int Invalid = -1;
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, Snowflake &s);
|
||||||
|
friend void to_json(nlohmann::json &j, const Snowflake &s);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend struct std::hash<Snowflake>;
|
||||||
|
friend struct std::less<Snowflake>;
|
||||||
|
unsigned long long m_num;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
template<>
|
||||||
|
struct hash<Snowflake> {
|
||||||
|
std::size_t operator()(const Snowflake &k) const {
|
||||||
|
return k.m_num;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct less<Snowflake> {
|
||||||
|
bool operator()(const Snowflake &l, const Snowflake &r) const {
|
||||||
|
return l.m_num < r.m_num;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
enum class GatewayOp : int {
|
||||||
|
Event = 0,
|
||||||
|
Heartbeat = 1,
|
||||||
|
Identify = 2,
|
||||||
|
Hello = 10,
|
||||||
|
HeartbeatAck = 11,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class GatewayEvent : int {
|
||||||
|
READY,
|
||||||
|
MESSAGE_CREATE,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GatewayMessage {
|
||||||
|
GatewayOp Opcode;
|
||||||
|
nlohmann::json Data;
|
||||||
|
std::string Type;
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, GatewayMessage &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HelloMessageData {
|
||||||
|
int HeartbeatInterval;
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, HelloMessageData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ChannelType : int {
|
||||||
|
GUILD_TEXT = 0,
|
||||||
|
DM = 1,
|
||||||
|
GUILD_VOICE = 2,
|
||||||
|
GROUP_DM = 3,
|
||||||
|
GUILD_CATEGORY = 4,
|
||||||
|
GUILD_NEWS = 5,
|
||||||
|
GUILD_STORE = 6,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UserData {
|
||||||
|
Snowflake ID; //
|
||||||
|
std::string Username; //
|
||||||
|
std::string Discriminator; //
|
||||||
|
std::string Avatar; // null
|
||||||
|
bool IsBot = false; // opt
|
||||||
|
bool IsSystem = false; // opt
|
||||||
|
bool IsMFAEnabled = false; // opt
|
||||||
|
std::string Locale; // opt
|
||||||
|
bool IsVerified = false; // opt
|
||||||
|
std::string Email; // opt, null
|
||||||
|
int Flags = 0; // opt
|
||||||
|
int PremiumType = 0; // opt
|
||||||
|
int PublicFlags = 0; // opt
|
||||||
|
|
||||||
|
// undocumented (opt)
|
||||||
|
bool IsDesktop = false; //
|
||||||
|
bool IsMobile = false; //
|
||||||
|
bool IsNSFWAllowed = false; // null
|
||||||
|
std::string Phone; // null?
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, UserData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ChannelData {
|
||||||
|
Snowflake ID; //
|
||||||
|
ChannelType Type; //
|
||||||
|
Snowflake GuildID; // opt
|
||||||
|
int Position = -1; // opt
|
||||||
|
// std::vector<PermissionOverwriteData> PermissionOverwrites; // opt
|
||||||
|
std::string Name; // opt
|
||||||
|
std::string Topic; // opt, null
|
||||||
|
bool IsNSFW = false; // opt
|
||||||
|
Snowflake LastMessageID; // opt, null
|
||||||
|
int Bitrate = 0; // opt
|
||||||
|
int UserLimit = 0; // opt
|
||||||
|
int RateLimitPerUser = 0; // opt
|
||||||
|
std::vector<UserData> Recipients; // opt
|
||||||
|
std::string Icon; // opt, null
|
||||||
|
Snowflake OwnerID; // opt
|
||||||
|
Snowflake ApplicationID; // opt
|
||||||
|
Snowflake ParentID; // opt, null
|
||||||
|
std::string LastPinTimestamp; // opt, can be null even tho docs say otherwise
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, ChannelData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
// a bot is apparently only supposed to receive the `id` and `unavailable` as false
|
||||||
|
// but user tokens seem to get the full objects (minus users)
|
||||||
|
struct GuildData {
|
||||||
|
Snowflake ID; //
|
||||||
|
std::string Name; //
|
||||||
|
std::string Icon; // null
|
||||||
|
std::string Splash; // null
|
||||||
|
std::string DiscoverySplash; // null
|
||||||
|
bool IsOwner = false; // opt
|
||||||
|
Snowflake OwnerID; //
|
||||||
|
int Permissions = 0; // opt
|
||||||
|
std::string PermissionsNew; // opt
|
||||||
|
std::string VoiceRegion; // opt
|
||||||
|
Snowflake AFKChannelID; // null
|
||||||
|
int AFKTimeout; //
|
||||||
|
bool IsEmbedEnabled = false; // opt, deprecated
|
||||||
|
Snowflake EmbedChannelID; // opt, null, deprecated
|
||||||
|
int VerificationLevel; //
|
||||||
|
int DefaultMessageNotifications; //
|
||||||
|
int ExplicitContentFilter; //
|
||||||
|
// std::vector<RoleData> Roles; //
|
||||||
|
// std::vector<EmojiData> Emojis; //
|
||||||
|
std::vector<std::string> Features; //
|
||||||
|
int MFALevel; //
|
||||||
|
Snowflake ApplicationID; // null
|
||||||
|
bool IsWidgetEnabled = false; // opt
|
||||||
|
Snowflake WidgetChannelID; // opt, null
|
||||||
|
Snowflake SystemChannelID; // null
|
||||||
|
int SystemChannelFlags; //
|
||||||
|
Snowflake RulesChannelID; // null
|
||||||
|
std::string JoinedAt; // opt*
|
||||||
|
bool IsLarge = false; // opt*
|
||||||
|
bool IsUnavailable = false; // opt*
|
||||||
|
int MemberCount = 0; // opt*
|
||||||
|
// std::vector<VoiceStateData> VoiceStates; // opt*
|
||||||
|
// std::vector<MemberData> Members; // opt* - incomplete anyways
|
||||||
|
std::vector<ChannelData> Channels; // opt*
|
||||||
|
// std::vector<PresenceUpdateData> Presences; // opt*
|
||||||
|
int MaxPresences = 0; // opt, null
|
||||||
|
int MaxMembers = 0; // opt
|
||||||
|
std::string VanityURL; // null
|
||||||
|
std::string Description; // null
|
||||||
|
std::string BannerHash; // null
|
||||||
|
int PremiumTier; //
|
||||||
|
int PremiumSubscriptionCount = 0; // opt
|
||||||
|
std::string PreferredLocale; //
|
||||||
|
Snowflake PublicUpdatesChannelID; // null
|
||||||
|
int MaxVideoChannelUsers = 0; // opt
|
||||||
|
int ApproximateMemberCount = 0; // opt
|
||||||
|
int ApproximatePresenceCount = 0; // opt
|
||||||
|
|
||||||
|
// undocumented
|
||||||
|
// std::map<std::string, Unknown> GuildHashes;
|
||||||
|
bool IsLazy = false;
|
||||||
|
|
||||||
|
// * - documentation says only sent in GUILD_CREATE, but these can be sent anyways in the READY event
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, GuildData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UserSettingsData {
|
||||||
|
int TimezoneOffset; //
|
||||||
|
std::string Theme; //
|
||||||
|
bool AreStreamNotificationsEnabled; //
|
||||||
|
std::string Status; //
|
||||||
|
bool ShouldShowCurrentGame; //
|
||||||
|
// std::vector<Unknown> RestrictedGuilds; //
|
||||||
|
bool ShouldRenderReactions; //
|
||||||
|
bool ShouldRenderEmbeds; //
|
||||||
|
bool IsNativePhoneIntegrationEnabled; //
|
||||||
|
bool ShouldMessageDisplayCompact; //
|
||||||
|
std::string Locale; //
|
||||||
|
bool ShouldInlineEmbedMedia; //
|
||||||
|
bool ShouldInlineAttachmentMedia; //
|
||||||
|
std::vector<Snowflake> GuildPositions; //
|
||||||
|
// std::vector<GuildFolderEntryData> GuildFolders; //
|
||||||
|
bool ShouldGIFAutoplay; //
|
||||||
|
// Unknown FriendSourceFlags; //
|
||||||
|
int ExplicitContentFilter; //
|
||||||
|
bool IsTTSCommandEnabled; //
|
||||||
|
bool ShouldDisableGamesTab; //
|
||||||
|
bool DeveloperMode; //
|
||||||
|
bool ShouldDetectPlatformAccounts; //
|
||||||
|
bool AreDefaultGuildsRestricted; //
|
||||||
|
// Unknown CustomStatus; // null
|
||||||
|
bool ShouldConvertEmoticons; //
|
||||||
|
bool IsContactSyncEnabled; //
|
||||||
|
bool ShouldAnimateEmojis; //
|
||||||
|
bool IsAccessibilityDetectionAllowed; //
|
||||||
|
int AFKTimeout;
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, UserSettingsData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class MessageType {
|
||||||
|
DEFAULT = 0,
|
||||||
|
RECIPIENT_ADD = 1,
|
||||||
|
RECIPIENT_REMOVE = 2,
|
||||||
|
CALL = 3,
|
||||||
|
CHANNEL_NaME_CHANGE = 4,
|
||||||
|
CHANNEL_ICON_CHANGE = 5,
|
||||||
|
CHANNEL_PINNED_MESSAGE = 6,
|
||||||
|
GUILD_MEMBER_JOIN = 6,
|
||||||
|
USER_PREMIUM_GUILD_SUBSCRIPTION = 7,
|
||||||
|
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = 8,
|
||||||
|
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 9,
|
||||||
|
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 10,
|
||||||
|
CHANNEL_FOLLOW_ADD = 12,
|
||||||
|
GUILD_DISCOVERY_DISQUALIFIED = 13,
|
||||||
|
GUILD_DISCOVERY_REQUALIFIED = 14,
|
||||||
|
};
|
||||||
|
|
||||||
|
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::string IconURL; // opt
|
||||||
|
std::string ProxyIconURL; // opt
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, EmbedFooterData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EmbedImageData {
|
||||||
|
std::string URL; // opt
|
||||||
|
std::string ProxyURL; // opt
|
||||||
|
int Height = 0; // opt
|
||||||
|
int Width = 0; // opt
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, EmbedImageData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EmbedThumbnailData {
|
||||||
|
std::string URL; // opt
|
||||||
|
std::string ProxyURL; // opt
|
||||||
|
int Height = 0; // opt
|
||||||
|
int Width = 0; // opt
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, EmbedThumbnailData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EmbedVideoData {
|
||||||
|
std::string URL; // opt
|
||||||
|
int Height = 0; // opt
|
||||||
|
int Width = 0; // opt
|
||||||
|
friend void from_json(const nlohmann::json &j, EmbedVideoData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EmbedProviderData {
|
||||||
|
std::string Name; // opt
|
||||||
|
std::string URL; // opt
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, EmbedProviderData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EmbedAuthorData {
|
||||||
|
std::string Name; // opt
|
||||||
|
std::string URL; // opt
|
||||||
|
std::string IconURL; // opt
|
||||||
|
std::string ProxyIconURL; // opt
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, EmbedAuthorData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EmbedFieldData {
|
||||||
|
std::string Name; //
|
||||||
|
std::string Value; //
|
||||||
|
bool Inline = false; // opt
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, EmbedFieldData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EmbedData {
|
||||||
|
std::string Title; // opt
|
||||||
|
std::string Type; // opt
|
||||||
|
std::string Description; // opt
|
||||||
|
std::string URL; // opt
|
||||||
|
std::string Timestamp; // opt
|
||||||
|
int Color = 0; // opt
|
||||||
|
EmbedFooterData Footer; // opt
|
||||||
|
EmbedImageData Image; // opt
|
||||||
|
EmbedThumbnailData Thumbnail; // opt
|
||||||
|
EmbedVideoData Video; // opt
|
||||||
|
EmbedProviderData Provider; // opt
|
||||||
|
EmbedAuthorData Author; // opt
|
||||||
|
std::vector<EmbedFieldData> Fields; // opt
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, EmbedData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MessageData {
|
||||||
|
Snowflake ID; //
|
||||||
|
Snowflake ChannelID; //
|
||||||
|
Snowflake GuildID; // opt
|
||||||
|
UserData Author; //
|
||||||
|
// GuildMemberData Member; // opt
|
||||||
|
std::string Content; //
|
||||||
|
std::string Timestamp; //
|
||||||
|
std::string EditedTimestamp; // null
|
||||||
|
bool IsTTS; //
|
||||||
|
bool DoesMentionEveryone; //
|
||||||
|
std::vector<UserData> Mentions; //
|
||||||
|
// std::vector<RoleData> 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
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, MessageData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ReadyEventData {
|
||||||
|
int GatewayVersion; //
|
||||||
|
UserData User; //
|
||||||
|
std::vector<GuildData> Guilds; //
|
||||||
|
std::string SessionID; //
|
||||||
|
// std::vector<ChannelData?/PrivateChannelData?> PrivateChannels;
|
||||||
|
|
||||||
|
// undocumented
|
||||||
|
std::string AnalyticsToken; // opt
|
||||||
|
int FriendSuggestionCount; // opt
|
||||||
|
UserSettingsData UserSettings; // opt
|
||||||
|
// std::vector<Unknown> ConnectedAccounts; // opt
|
||||||
|
// std::map<std::string, Unknown> Consents; // opt
|
||||||
|
// std::vector<Unknown> Experiments; // opt
|
||||||
|
// std::vector<Unknown> GuildExperiments; // opt
|
||||||
|
// std::map<Unknown, Unknown> Notes; // opt
|
||||||
|
// std::vector<PresenceData> Presences; // opt
|
||||||
|
// std::vector<ReadStateData> ReadStates; // opt
|
||||||
|
// std::vector<RelationshipData> Relationships; // opt
|
||||||
|
// Unknown Tutorial; // opt, null
|
||||||
|
// std::vector<GuildSettingData> UserGuildSettings; // opt
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, ReadyEventData &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IdentifyProperties {
|
||||||
|
std::string OS;
|
||||||
|
std::string Browser;
|
||||||
|
std::string Device;
|
||||||
|
|
||||||
|
friend void to_json(nlohmann::json &j, const IdentifyProperties &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IdentifyMessage : GatewayMessage {
|
||||||
|
std::string Token;
|
||||||
|
IdentifyProperties Properties;
|
||||||
|
bool DoesSupportCompression = false;
|
||||||
|
int LargeThreshold = 0;
|
||||||
|
|
||||||
|
friend void to_json(nlohmann::json &j, const IdentifyMessage &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HeartbeatMessage : GatewayMessage {
|
||||||
|
int Sequence;
|
||||||
|
|
||||||
|
friend void to_json(nlohmann::json &j, const HeartbeatMessage &m);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CreateMessageObject {
|
||||||
|
std::string Content;
|
||||||
|
|
||||||
|
friend void to_json(nlohmann::json &j, const CreateMessageObject &m);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user