#ifndef INTERFACE_MESSAGE_HPP_ #define INTERFACE_MESSAGE_HPP_ #include #include class Message { private: const nlohmann::json& data; WebSocket& web; NetworkManager& req; public: Message(const nlohmann::json& json) : data(json), web(WebSocket::getInstance()), req(NetworkManager::getInstance()) {}; auto send(const std::string& id, const nlohmann::json& msg) -> std::string { return req.request(HttpMethods::POST, DiscordEndpoints::details::latest + "/channels/" + id + "/messages", msg.dump()); } auto getMessages(const std::string& id, const std::string& count, const std::string& before = "") -> std::string { if (before.empty()) { return req.request(HttpMethods::GET, DiscordEndpoints::details::latest + "/channels/" + id + "/messages?limit=" + count); } else { return req.request(HttpMethods::GET, DiscordEndpoints::details::latest + "/channels/" + id + "/messages?before=" + before + "&limit=" + count); } return ""; } auto deleteMessage(const std::string& channel_id, const std::string& message_id) -> std::string { return req.request(HttpMethods::DELETE, DiscordEndpoints::details::latest + "/channels/" + channel_id + "/messages/" + message_id); } _nodiscard auto pack(const nlohmann::json& key, const std::string& value) const -> nlohmann::json { return { { key, value } }; } struct Api { const nlohmann::json& data; NetworkManager& req; Api(const nlohmann::json& json) : data(json), req(NetworkManager::getInstance()) {}; _nodiscard auto latency() const -> unsigned long { return req.getLatency(); } }; }; #endif