[Bots] Convert Bot Database Methods to Repositories (#4023)

* [Bots] Convert Bot Database Methods to Repositories

* Final push.

* Cleanup.

* Cleanup.

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp
This commit is contained in:
Alex King
2024-01-28 21:23:31 -05:00
committed by GitHub
parent 7a770e0e08
commit ce907c9519
31 changed files with 3570 additions and 2679 deletions
@@ -44,7 +44,36 @@ public:
*/
// Custom extended repository methods here
static bool SaveAllInspectMessages(Database& db, const uint32 owner_id, const std::string& inspect_message)
{
auto results = db.QueryDatabase(
fmt::format(
SQL(
INSERT INTO `bot_inspect_messages` (`bot_id`, `inspect_message`) VALUES
(SELECT `bot_id`, '{}' inspect_message FROM `bot_data` WHERE `owner_id` = {})
),
inspect_message,
owner_id
)
);
return results.Success();
}
static bool DeleteAllInspectMessages(Database& db, const uint32 owner_id)
{
auto results = db.QueryDatabase(
fmt::format(
SQL(
DELETE FROM `bot_inspect_messages`
WHERE `bot_id` IN (SELECT `bot_id` FROM `bot_data` WHERE `owner_id` = {})
),
owner_id
)
);
return results.Success();
}
};
#endif //EQEMU_BOT_INSPECT_MESSAGES_REPOSITORY_H