Update lookup command (#909)

* Update lookup command

* Fix bugs

Update SlashCommandHandler.cpp
This commit is contained in:
David Markowitz
2023-01-06 22:17:09 -08:00
committed by GitHub
parent a28a2e60cf
commit a580e3a2f5
2 changed files with 9 additions and 3 deletions

View File

@@ -1198,11 +1198,17 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
EntityManager::Instance()->SerializeEntity(entity);
}
if (chatCommand == "lookup" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() == 1) {
if (chatCommand == "lookup" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
auto query = CDClientDatabase::CreatePreppedStmt(
"SELECT `id`, `name` FROM `Objects` WHERE `displayName` LIKE ?1 OR `name` LIKE ?1 OR `description` LIKE ?1 LIMIT 50");
// Concatenate all of the arguments into a single query so a multi word query can be used properly.
std::string conditional = args[0];
args.erase(args.begin());
for (auto& argument : args) {
conditional += ' ' + argument;
}
const std::string query_text = "%" + args[0] + "%";
const std::string query_text = "%" + conditional + "%";
query.bind(1, query_text.c_str());
auto tables = query.execQuery();