[Commands] Cleanup #getvariable Command. (#2100)

- Cleanup messages and logic.
This commit is contained in:
Kinglykrab
2022-05-03 23:05:02 -04:00
committed by GitHub
parent b2b87ea4e0
commit e08afb1234
2 changed files with 24 additions and 6 deletions
+23 -5
View File
@@ -2,12 +2,30 @@
void command_getvariable(Client *c, const Seperator *sep)
{
std::string tmp;
if (database.GetVariable(sep->argplus[1], tmp)) {
c->Message(Chat::White, "%s = %s", sep->argplus[1], tmp.c_str());
std::string variable = sep->argplus[1];
if (variable.empty()) {
c->Message(Chat::White, "Usage: #getvariable [Variable Name]");
return;
}
else {
c->Message(Chat::White, "GetVariable(%s) returned false", sep->argplus[1]);
std::string message;
std::string value;
if (database.GetVariable(variable, value)) {
message = fmt::format(
"Variable {}: {}",
variable,
value
);
} else {
message = fmt::format(
"Variable '{}' does not exist.",
variable
);
}
c->Message(
Chat::White,
message.c_str()
);
}