[Commands] Cleanup #refreshgroup Command. (#2119)

- Cleanup messages and logic.
This commit is contained in:
Kinglykrab
2022-05-06 20:42:25 -04:00
committed by GitHub
parent 6bbd1e94c3
commit 2f962c2c8a
3 changed files with 65 additions and 21 deletions
+48 -7
View File
@@ -3,17 +3,58 @@
void command_refreshgroup(Client *c, const Seperator *sep)
{
if (!c) {
auto target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
target = c->GetTarget()->CastToClient();
}
Group *group = target->GetGroup();
if (!group) {
c->Message(
Chat::White,
fmt::format(
"{} not in a group.",
(
c == target ?
"You are" :
fmt::format(
"{} ({}} is",
target->GetCleanName(),
target->GetID()
)
)
).c_str()
);
return;
}
Group *g = c->GetGroup();
database.RefreshGroupFromDB(target);
if (!g) {
return;
c->Message(
Chat::White,
fmt::format(
"Group has been refreshed for {}.",
(
c == target ?
"yourself" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
)
).c_str()
);
if (c != target) {
target->Message(
Chat::White,
fmt::format(
"Your group has been refreshed by {}.",
c->GetCleanName()
).c_str()
);
}
database.RefreshGroupFromDB(c);
//g->SendUpdate(7, c);
}