This commit is contained in:
fluttershy 2025-01-20 01:52:54 +05:00
commit 626ddc1121

View File

@ -2,48 +2,13 @@
#include <includes.h> #include <includes.h>
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
if (argc != 3) return -1; if (argc != 3) return -1;
WebSocket* bot = &WebSocket::getInstance(argv[2], GatewayIntents::AllIntents, false); WebSocket* bot = &WebSocket::getInstance(argv[2], GatewayIntents::AllIntents);
bot->on(GatewayEvents::READY, [](const Discord<Message, User, Author>& msg) { bot->on(GatewayEvents::READY, [](const Discord<Message, User>a) {
std::string lastID = "1221155685518278708"; cout << DiscordEndpoints::details::latest << endl;
while (true) { });
std::vector<std::string> ids; bot->on(GatewayEvents::MESSAGE_CREATE, [](const Discord<Message, User, Author> msg) {
std::cout << "Last ID: " << lastID << std::endl; g(0, msg.net)->send("939957962972229634", j("content", g(2, msg.net)->content()));
json js = json::parse(g(0, msg.net)->getMessages("956854968260890654", "100", lastID));
if (js.is_array() && !js.empty()) {
int counter = 0;
for (const auto& message : js) {
if (message["author"]["id"] == "956790566463614986") {
printf("\rMessage ID: %s %d", message["id"].get<std::string>().c_str(), ++counter);
ids.emplace_back(message["id"].get<std::string>());
}
else {
lastID = message["id"].get<std::string>();
}
}
cout << endl;
if (ids.size() > 1) {
for (unsigned long x = 0; x < ids.size(); x++) {
try {
json jss = json::parse(g(0, msg.net)->deleteMessage("956854968260890654", ids[x]));
if (jss["code"].get<string>() == "20028") {
std::this_thread::sleep_for(15s);
}
std::cout << "Delete response: " << jss["message"] << ":" << jss["code"] << std::endl;
}
catch (...) {
std::cout << "\rDeleted ID: " << ids[x] << " " << x + 1;
std::cout.flush();
}
std::this_thread::sleep_for(200ms);
}
cout << endl;
}
}
else {
std::cout << "No messages found or error in response." << std::endl;
}
}
}); });
bot->start(); bot->start();
return 0; return 0;
} }