#ifndef API_BOT_HPP_ #define API_BOT_HPP_ #include template class Discord { private: std::tuple...> net; nlohmann::json data; void initializeNets(const nlohmann::json& data) { initializeNetsImpl(data, std::index_sequence_for{}); } template void initializeNetsImpl(const nlohmann::json& data, std::index_sequence) { net = std::make_tuple(std::make_unique(data)...); } public: Discord(const nlohmann::json& data) : data(data) { initializeNets(data); } template auto& get() const { return *std::get(net); } }; class Bot { private: 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