This repository has been archived on 2025-03-15. You can view files and clone it, but cannot push or open issues or pull requests.
sparkle/libs/api/Bot.hpp
fluttershy f5341d6ea5 fixes
2025-01-27 17:24:33 +05:00

35 lines
844 B
C++

#ifndef API_BOT_HPP_
#define API_BOT_HPP_
#include <includes.hpp>
template<typename...Args>
class Discord {
private:
const nlohmann::json& data;
std::tuple<std::unique_ptr<Args>...> net;
public:
Discord(const nlohmann::json& data) : data(data), net(std::make_tuple(std::make_unique<Args>(data)...)) {}
template<class T>
[[deprecated("Use ctx() instead")]] auto& get() const {
return *std::get<std::unique_ptr<T>>(net);
}
const auto& ctx() const {
return net;
}
};
class Bot {
private:
const nlohmann::json& data;
public:
Bot(const nlohmann::json& data) : data(data) {};
std::string id() const {
return data["d"]["id"];
}
bool isBot() const {
try {
return data["d"]["bot"];
} catch (...) {
return false;
}
}
};
#endif