#ifndef INTERFACE_USER_HPP_ #define INTERFACE_USER_HPP_ #include #include #include class User { private: const nlohmann::json& data; WebSocket& web; NetworkManager& req; public: User(const nlohmann::json& data) : data(data), web(WebSocket::getInstance()), req(NetworkManager::getInstance()), isBot(false) { auto botValue = functions::testValue(data, { "d", "user", "bot" }); if (botValue.has_value()) { isBot = botValue.value(); } } bool isBot; nlohmann::json extract(const std::vector& keys) { std::vector d = { "d" }; d.insert(d.end(), keys.begin(), keys.end()); nlohmann::json current = data; for (const auto& key : d) { if (current.contains(key)) { current = current[key]; } else { return "Key not found."; } } return current; }; std::string me() { return req.request(HttpMethods::GET, DiscordEndpoints::details::latest + "/users/@me"); } }; #endif