message container

main
Brett 2024-03-03 23:47:54 -05:00
parent b440f902f9
commit d6e9a878f6
1 changed files with 49 additions and 4 deletions

View File

@ -17,6 +17,23 @@
namespace sql = sqlite_orm; namespace sql = sqlite_orm;
using namespace db; using namespace db;
struct discord_message
{
private:
std::string message;
public:
template<typename T>
discord_message& operator+=(T&& t)
{
message += std::forward<T>(t);
}
void send()
{
}
};
struct db_obj struct db_obj
{ {
private: private:
@ -56,6 +73,13 @@ struct db_obj
return db.count<server_info_t>(); return db.count<server_info_t>();
} }
inline void printMessages()
{
using namespace sql;
auto data = db.select(object<message_t>);
}
void load(dpp::cluster& bot, const dpp::guild& guild) void load(dpp::cluster& bot, const dpp::guild& guild)
{ {
server_info_t server_inf; server_info_t server_inf;
@ -464,13 +488,34 @@ int main(int argc, const char** argv)
return; return;
if (blt::string::starts_with(event.msg.content, "!dump")) 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) for (auto& db : databases)
{ {
event.send("----------{GuildID: " + std::to_string(db.first) + "}----------"); message += "----------{GuildID: ";
event.send("Member Count: " + std::to_string(db.second->users())); message += std::to_string(db.first);
event.send("Messages: " + std::to_string(db.second->messages())); 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); auto& storage = get(event.msg.guild_id);
message_t message; message_t message;