Kinglykrab d9c41526e8
[Commands] Cleanup #ban, #ipban, #flag, #kick, #setlsinfo, and #setpass Commands. (#2104)
* [Commands] Cleanup #ban, #ipban, #flag, and #kick Commands.
- Cleanup messages and logic.
- Add ServerFlagUpdate_Struct for flag updates.

* Add #setlsinfo and #setpass to cleanup.

* Update setlsinfo.cpp

* Update database.cpp

* Update database.cpp

* Update command.cpp
2022-05-07 23:28:45 -04:00

52 lines
1013 B
C++
Executable File

#include "../client.h"
void command_setpass(Client *c, const Seperator *sep)
{
int arguments = sep->argnum;
if (arguments < 2) {
c->Message(Chat::White, "Usage: #setpass [Account Name] [Password]");
return;
}
std::string account_name;
std::string loginserver;
ParseAccountString(sep->arg[1], account_name, loginserver);
int16 status = 0;
auto account_id = database.GetAccountIDByName(account_name, loginserver, &status);
if (!account_id) {
c->Message(
Chat::White,
fmt::format(
"Account {} not found.",
account_name
).c_str()
);
return;
}
if (status > c->Admin()) {
c->Message(
Chat::White,
fmt::format(
"You cannot change the password for Account {} as its status is higher than yours.",
account_name
).c_str()
);
return;
}
c->Message(
Chat::White,
fmt::format(
"Password {} changed for Account {}.",
(
database.SetLocalPassword(account_id, sep->arg[2]) ?
"successfully" :
"failed"
),
account_name
).c_str()
);
}