From 4b903bbd3e8436e1d63b8c12e76d8a3c924da5fc Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Wed, 19 Aug 2020 21:08:57 -0400 Subject: add http client and channel reordering (waste of time) --- discord/discord.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'discord/discord.hpp') diff --git a/discord/discord.hpp b/discord/discord.hpp index 3c27efe..fa09ce2 100644 --- a/discord/discord.hpp +++ b/discord/discord.hpp @@ -1,5 +1,6 @@ #pragma once #include "websocket.hpp" +#include "http.hpp" #include #include #include @@ -21,9 +22,14 @@ struct Snowflake { 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; @@ -286,6 +292,8 @@ private: class Abaddon; class DiscordClient { + friend class Abaddon; + public: static const constexpr char *DiscordGateway = "wss://gateway.discord.gg/?v=6&encoding=json"; static const constexpr char *DiscordAPI = "https://discord.com/api"; @@ -301,6 +309,10 @@ public: using Guilds_t = std::unordered_map; const Guilds_t &GetGuilds() const; const UserSettingsData &GetUserSettings() const; + std::vector> GetUserSortedGuilds() const; + void UpdateSettingsGuildPositions(const std::vector &pos); + + void UpdateToken(std::string token); private: void HandleGatewayMessage(nlohmann::json msg); @@ -309,6 +321,10 @@ private: void SendIdentify(); Abaddon *m_abaddon = nullptr; + HTTPClient m_http; + + std::string m_token; + mutable std::mutex m_mutex; void StoreGuild(Snowflake id, const GuildData &g); -- cgit v1.2.3