This commit is contained in:
fluttershy 2025-01-25 15:46:27 +05:00
parent b978dd998f
commit 2ee04ba9ca
3 changed files with 7 additions and 6 deletions

View File

@ -7,4 +7,5 @@
#include <utils/functions.hpp>
#include <iostream>
#include <string>
#include <memory>
#endif

View File

@ -1,6 +1,7 @@
#ifndef API_BOT_HPP_
#define API_BOT_HPP_
#include <includes.hpp>
#include <variant>
template<typename...Args>
class Discord {
private:
@ -17,9 +18,9 @@ public:
Discord(const nlohmann::json& data) : data(data) {
initializeNets(data);
}
template<unsigned long Index>
template<class T>
auto& get() const {
return *std::get<Index>(net);
return *std::get<std::unique_ptr<T>>(net);
}
};
class Bot {

View File

@ -6,10 +6,9 @@ int main(int argc, char* argv[]) {
bot->on(GatewayEvents::READY, [](const nlohmann::json&) {
std::cout << DiscordEndpoints::details::latest << std::endl;
});
bot->on(GatewayEvents::MESSAGE_CREATE, [](const Discord<Message, User, Author, Message::Api>& msg) {
if (!msg.get<2>().isBot) {
msg.get<0>().send("939957962972229634", msg.get<0>().pack("content", msg.get<2>().avatar));
msg.get<0>().send("939957962972229634", msg.get<0>().pack("content", std::to_string(msg.get<3>().latency()) + "ms"));
bot->on(GatewayEvents::MESSAGE_CREATE, [](const Discord<Message, User, Author, Message::Api>& ctx) {
if (!ctx.get<Author>().isBot) {
ctx.get<Message>().send("939957962972229634", ctx.get<Message>().pack("content", ctx.get<Author>().avatar));
}
});
bot->start();