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/Author.hpp
fluttershy 7f6b7e4bb6 fixes
2025-01-14 16:14:01 +05:00

61 lines
1.4 KiB
C++

#ifndef API_AUTHOR_HPP_
#define API_AUTHOR_HPP_
#include <utils/types.hpp>
#include <api/Channel.hpp>
#include <string>
#include <iostream>
using std::string;
using std::cout;
using std::endl;
class Author {
private:
json data;
WebSocket& web;
NetworkManager& req;
public:
Author(const json& data) : data(data), web(WebSocket::getInstance()), req(NetworkManager::getInstance()) {}
string content() {
try {
return data["d"]["content"];
}
catch (...) {
return "";
}
}
string channel_id() {
return data["d"]["channel_id"];
}
string id() {
return data["d"]["author"]["id"];
}
string global_name() {
return data["d"]["author"]["global_name"].dump();
}
string discriminator() {
return data["d"]["author"]["discriminator"];
}
bool isBot() {
try {
return data["d"]["author"]["bot"];
}
catch (...) {
return 0;
}
}
string guild_id() {
return data["d"]["guild_id"];
}
string msg_id() {
return data["d"]["id"];
}
bool isPinned() {
return data["d"]["pinned"];
}
string avatar() {
return data["d"]["author"]["avatar"];
}
string send(const json& msg) {
return req.request("POST", dapi + "/channels/" + data["d"]["channel_id"].get<string>() + "/messages", msg.dump());
}
};
#endif