#ifndef API_USER_HPP_
#define API_USER_HPP_
#include <includes.h>
#include <net.h>
#include <vector>
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<string>& keys) {
std::vector<string> 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(HttpMethods::GET, DiscordEndpoints::details::latest + "/users/@me");
bool isBot() const {
try {
return data["d"]["author"]["bot"];
catch (...) {
return false;
};
#endif