forked from rcxpony/sparkle
25 lines
729 B
C++
25 lines
729 B
C++
#ifndef API_CHANNEL_HPP_
|
|
#define API_CHANNEL_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 Channel {
|
|
private:
|
|
json data;
|
|
WebSocket& web;
|
|
NetworkManager& req;
|
|
public:
|
|
Channel(const json& data) : data(data), web(*WebSocket::getInstance(TOKEN_BOT, ALL_INTENTS)), req(*NetworkManager::getInstance()) {}
|
|
string send(const json& msg) const {
|
|
return req.request("POST", dapi + "/channels/" + data["d"]["channel_id"].get<string>() + "/messages", web.getToken(), msg.dump());
|
|
}
|
|
};
|
|
#endif |