#ifndef API_USER_HPP_ #define API_USER_HPP_ #include #include #include using std::string, std::cout, std::endl, nlohmann::json; class User { private: json data; WebSocket& web; NetworkManager& req; public: User(const json& data = "") : data(data), web(WebSocket::getInstance()), req(NetworkManager::getInstance()) {} json extract(const std::vector& keys) { std::vector d = { "d" }; d.insert(d.end(), keys.begin(), keys.end()); json current = data; for (const auto& key : d) { if (current.contains(key)) { current = current[key]; } else { return "Key not found."; } } return current; } virtual string me() { return req.request("GET", dapi + "/users/@me"); } bool isBot() { try { return data["d"]["author"]["bot"]; } catch (...) { return false; } } }; #endif