From 2ee04ba9cab317f265a6b45a38ac94c718aaea4f Mon Sep 17 00:00:00 2001 From: fluttershy Date: Sat, 25 Jan 2025 15:46:27 +0500 Subject: [PATCH] patches --- include/includes.hpp | 1 + libs/api/Bot.hpp | 5 +++-- sources/main.cpp | 7 +++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/includes.hpp b/include/includes.hpp index c214431..fdc0b64 100644 --- a/include/includes.hpp +++ b/include/includes.hpp @@ -7,4 +7,5 @@ #include #include #include +#include #endif \ No newline at end of file diff --git a/libs/api/Bot.hpp b/libs/api/Bot.hpp index d1f0a06..7a95b43 100644 --- a/libs/api/Bot.hpp +++ b/libs/api/Bot.hpp @@ -1,6 +1,7 @@ #ifndef API_BOT_HPP_ #define API_BOT_HPP_ #include +#include template class Discord { private: @@ -17,9 +18,9 @@ public: Discord(const nlohmann::json& data) : data(data) { initializeNets(data); } - template + template auto& get() const { - return *std::get(net); + return *std::get>(net); } }; class Bot { diff --git a/sources/main.cpp b/sources/main.cpp index 1abca0f..d8b1567 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -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& 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& ctx) { + if (!ctx.get().isBot) { + ctx.get().send("939957962972229634", ctx.get().pack("content", ctx.get().avatar)); } }); bot->start();