From d6e9a878f66d76c89ab359249ba41129d4e11afc Mon Sep 17 00:00:00 2001 From: Brett Date: Sun, 3 Mar 2024 23:47:54 -0500 Subject: [PATCH] message container --- src/main.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 66cae16..f678608 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,6 +17,23 @@ namespace sql = sqlite_orm; using namespace db; +struct discord_message +{ + private: + std::string message; + public: + template + discord_message& operator+=(T&& t) + { + message += std::forward(t); + } + + void send() + { + + } +}; + struct db_obj { private: @@ -56,6 +73,13 @@ struct db_obj return db.count(); } + inline void printMessages() + { + using namespace sql; + auto data = db.select(object); + + } + void load(dpp::cluster& bot, const dpp::guild& guild) { server_info_t server_inf; @@ -464,13 +488,34 @@ int main(int argc, const char** argv) return; if (blt::string::starts_with(event.msg.content, "!dump")) { - event.send("Server Count: " + std::to_string(databases.size())); + std::string message = "Server Count: "; + message += std::to_string(databases.size()); + message += '\n'; for (auto& db : databases) { - event.send("----------{GuildID: " + std::to_string(db.first) + "}----------"); - event.send("Member Count: " + std::to_string(db.second->users())); - event.send("Messages: " + std::to_string(db.second->messages())); + message += "----------{GuildID: "; + message += std::to_string(db.first); + message += "}----------"; + message += '\n'; + message += "Member Count: "; + message += std::to_string(db.second->users()); + message += '\n'; + message += "Messages: "; + message += std::to_string(db.second->messages()); + message += '\n'; } + while (message.length() > 2000) + { + auto message_view = std::string_view(message).substr(0, 2000); + auto pos = message_view.find_last_of('\n'); + event.send(message.substr(0, pos)); + message = message.substr(pos); + } + } + if (blt::string::starts_with(event.msg.content, "!messages")) + { + for (auto& db : databases) + db.second->printMessages(); } auto& storage = get(event.msg.guild_id); message_t message;