sparkle/libs/api/User.hpp
fluttershy 9205584e70 test
2025-01-27 22:02:21 +05:00

39 lines
1.1 KiB
C++

#ifndef API_USER_HPP_
#define API_USER_HPP_
#include <includes.hpp>
#include <net.hpp>
#include <vector>
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<bool>(data, { "d", "user", "bot" });
if (botValue.has_value()) {
isBot = botValue.value();
}
}
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