[Commands] Cleanup #chat Command. (#2581)

- Cleanup messages and logic.
This commit is contained in:
Alex King
2022-11-26 19:28:28 -05:00
committed by GitHub
parent f7ae5850f0
commit 253f4c07e0
2 changed files with 10 additions and 5 deletions
+9 -4
View File
@@ -5,11 +5,16 @@ extern WorldServer worldserver;
void command_chat(Client *c, const Seperator *sep)
{
if (sep->arg[2][0] == 0) {
c->Message(Chat::White, "Usage: #chat [channum] [message]");
auto arguments = sep->argnum;
if (arguments < 2 || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #chat [Channel ID] [Message]");
return;
}
else if (!worldserver.SendChannelMessage(0, 0, (uint8) atoi(sep->arg[1]), 0, 0, 100, sep->argplus[2])) {
c->Message(Chat::White, "Error: World server disconnected");
auto channel_id = static_cast<uint8>(std::stoul(sep->arg[1]));
std::string message = sep->argplus[2];
if (!worldserver.SendChannelMessage(0, 0, channel_id, 0, 0, 100, message.c_str())) {
c->Message(Chat::White, "World server is disconnected.");
}
}