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/interface/Author.hpp
2025-03-15 14:46:51 +05:00

45 lines
2.0 KiB
C++

#ifndef INTERFACE_AUTHOR_HPP_
#define INTERFACE_AUTHOR_HPP_
#include <pch.hpp>
#include <network.hpp>
class Author {
private:
const nlohmann::json& data;
WebSocket& web;
NetworkManager& req;
public:
_deprecated_t("requires update")
struct Channel {
std::string channel_id;
std::string global_name;
std::string id;
std::string content;
std::string avatar;
std::string guild_id;
std::string discriminator;
std::string message_id;
bool isPinned;
bool isBot;
} authorData;
const std::string channel_id, global_name, id, content, avatar, guild_id, discriminator, message_id;
bool isPinned, isBot;
Author(const nlohmann::json& data)
: data(data),
web(WebSocket::getInstance()),
req(NetworkManager::getInstance()),
channel_id(functions::testValue<std::string>(data, { "d", "channel_id" }).value_or("")),
global_name(functions::testValue<std::string>(data, { "d", "member", "user", "display_name" }).value_or("")),
id(functions::testValue<std::string>(data, { "d", "author", "id" }).value_or("")),
content(functions::testValue<std::string>(data, { "d", "content" }).value_or("")),
avatar(functions::testValue<std::string>(data, { "d", "author", "avatar" }).value_or("")),
guild_id(functions::testValue<std::string>(data, { "d", "guild_id" }).value_or("")),
discriminator(functions::testValue<std::string>(data, { "d", "author", "discriminator" }).value_or("")),
message_id(functions::testValue<std::string>(data, { "d", "id" }).value_or("")),
isPinned(functions::testValue<bool>(data, { "d", "pinned" }).value_or(false)),
isBot(functions::testValue<bool>(data, { "d", "author", "bot" }).value_or(false)) {
}
auto send(const nlohmann::json& msg) -> std::string {
return req.request(HttpMethods::POST, DiscordEndpoints::details::latest + "/channels/" + data["d"]["channel_id"].get<std::string>() + "/messages", msg.dump());
}
};
#endif