sparkle/libs/api/Message.hpp
ZZMOaG(vj3GeCEpn7k76EZFEj_PL$%u@9)Oxp;BrMykYFFxC
 1fb42627b1 added
2024-12-31 02:20:56 +05:00

25 lines
707 B
C++

#ifndef API_MESSAGE_HPP_
#define API_MESSAGE_HPP_
#include <utils/json.hpp>
#include <string>
#include <exception>
#include <iostream>
#include <tls/network.hpp>
#include <gateway/websocket.hpp>
#include <utils/types.hpp>
using std::string;
using std::cout;
using std::endl;
using json = nlohmann::json;
class Message {
private:
json data;
WebSocket& web;
NetworkManager& req;
public:
Message(const json& data) : data(data), web(*WebSocket::getInstance(TOKEN_BOT, ALL_INTENTS)), req(*NetworkManager::getInstance()) {};
string send(const string& id, const json& msg) {
return req.request("POST", dapi + "/channels/" + id + "/messages", web.getToken(), msg.dump());
}
};
#endif