#include #include #include int main(int argc, char* argv[]) { cxxopts::Options options("sparkle", "WIP discord bot library in C++"); options.add_options() ("h,help", "Print help") ("V,version", "Show version information") ("t,token", "Discord bot token", cxxopts::value()); auto result = options.parse(argc, argv); if (result.count("version")) { std::cout << "sparkle version 0.3" << std::endl; return 0; } if (result.count("help")) { std::cout << options.help() << std::endl; return 0; } if (!result.contains("token")) { std::cout << "\033[31mError: no token provided.\033[0m" << std::endl; std::cout << options.help() << std::endl; return -1; } WebSocket* bot = &WebSocket::getInstance(result["token"].as(), GatewayIntents::AllIntents); bot->on(GatewayEvents::READY, [](const Discord& ctx) { auto& [user] = ctx.ctx(); std::cout << nlohmann::json::parse(user->me())["username"].get() << std::endl; }); bot->on(GatewayEvents::MESSAGE_CREATE, [](const Discord& msg) { const auto& [message, user, author] = msg.ctx(); if (!author->isBot) { message->send("939957962972229634", message->pack("content", author->channel_id)); } }); bot->on(GatewayEvents::MESSAGE_REACTION_ADD, [](const Discord& msg) { const auto& [message] = msg.ctx(); message->send("939957962972229634", message->pack("content", "test")); }); bot->start(); return 0; }