sparkle/libs/api/User.hpp
2025-01-26 23:33:52 +05:00

35 lines
1.0 KiB
C++

#ifndef API_USER_HPP_
#define API_USER_HPP_
#include <includes.hpp>
#include <net.hpp>
#include <vector>
class User {
private:
nlohmann::json data;
WebSocket& web;
NetworkManager& req;
public:
User(const nlohmann::json& data = "") : data(data), web(WebSocket::getInstance()), req(NetworkManager::getInstance()),
isBot(data["d"]["user"].contains("bot") ? data["d"]["user"]["bot"].get<bool>() : false) {
}
bool isBot;
/*
nlohmann::json extract(const std::vector<std::string>& keys) {
std::vector<std::string> 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