[Bug Fix] Fix case-sensitivity in #suspend Command. (#2613)

* [Bug Fix] Fix case-sensitivity in #suspend Command.

# Notes
- This command required you to properly send the name as it appears in the database otherwise it wouldn't kick the player.
- Solution is to `Strings::ToLower` then `Strings::UcFirst`.

* To lower.
This commit is contained in:
Alex King 2022-12-05 00:17:17 -05:00 committed by GitHub
parent a9c161011e
commit ef42e00df8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,35 +13,35 @@ void command_suspend(Client *c, const Seperator *sep)
return; return;
} }
const std::string character_name = sep->arg[1]; const std::string character_name = Strings::ToLower(sep->arg[1]);
auto days = std::stoul(sep->arg[2]); auto days = std::stoul(sep->arg[2]);
const std::string reason = sep->arg[3] ? sep->argplus[3] : ""; const std::string reason = sep->arg[3] ? sep->argplus[3] : "";
auto a = AccountRepository::GetWhere( auto l = AccountRepository::GetWhere(
content_db, content_db,
fmt::format( fmt::format(
"charname = '{}'", "LOWER(charname) = '{}'",
Strings::Escape(character_name) Strings::Escape(character_name)
) )
); );
if (a.empty() || !a[0].id) { if (l.empty()) {
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
"Character {} does not exist.", "Character '{}' does not exist.",
character_name sep->arg[1]
).c_str() ).c_str()
); );
return; return;
} }
a[0].status = -1; l[0].status = -1;
a[0].suspendeduntil = std::time(nullptr) + (days * 86400); l[0].suspendeduntil = std::time(nullptr) + (days * 86400);
a[0].suspend_reason = reason; l[0].suspend_reason = reason;
if (!AccountRepository::UpdateOne(content_db, a[0])) { if (!AccountRepository::UpdateOne(content_db, l[0])) {
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
@ -56,8 +56,8 @@ void command_suspend(Client *c, const Seperator *sep)
Chat::White, Chat::White,
fmt::format( fmt::format(
"Account {} ({}) with the character {} {}.", "Account {} ({}) with the character {} {}.",
a[0].name, l[0].name,
a[0].id, l[0].id,
character_name, character_name,
( (
days ? days ?