[Commands] Cleanup #enablerecipe Command. (#1817)

- Cleanup message and logic.
This commit is contained in:
Kinglykrab 2021-11-23 21:45:52 -05:00 committed by GitHub
parent 6fa41a3b73
commit 8b5b19ae2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 24 deletions

View File

@ -165,7 +165,7 @@ int command_init(void)
command_add("emotesearch", "Searches NPC Emotes", AccountStatus::QuestTroupe, command_emotesearch) ||
command_add("emoteview", "Lists all NPC Emotes", AccountStatus::QuestTroupe, command_emoteview) ||
command_add("emptyinventory", "- Clears you or your target's entire inventory (Equipment, General, Bank, and Shared Bank)", AccountStatus::GMImpossible, command_emptyinventory) ||
command_add("enablerecipe", "[recipe_id] - Enables a recipe using the recipe id.", AccountStatus::QuestTroupe, command_enablerecipe) ||
command_add("enablerecipe", "[Recipe ID] - Enables a Recipe", AccountStatus::QuestTroupe, command_enablerecipe) ||
command_add("endurance", "Restores you or your target's endurance.", AccountStatus::Guide, command_endurance) ||
command_add("equipitem", "[slotid(0-21)] - Equip the item on your cursor into the specified slot", AccountStatus::Guide, command_equipitem) ||
command_add("face", "- Change the face of your target", AccountStatus::QuestTroupe, command_face) ||

View File

@ -2,28 +2,28 @@
void command_enablerecipe(Client *c, const Seperator *sep)
{
uint32 recipe_id = 0;
bool success = false;
if (c) {
if (sep->argnum == 1) {
recipe_id = atoi(sep->arg[1]);
}
else {
c->Message(Chat::White, "Invalid number of arguments.\nUsage: #enablerecipe recipe_id");
return;
}
if (recipe_id > 0) {
success = content_db.EnableRecipe(recipe_id);
if (success) {
c->Message(Chat::White, "Recipe enabled.");
}
else {
c->Message(Chat::White, "Recipe not enabled.");
}
}
else {
c->Message(Chat::White, "Invalid recipe id.\nUsage: #enablerecipe recipe_id");
}
int arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #enablerecipe [Recipe ID]");
return;
}
}
auto recipe_id = std::stoul(sep->arg[1]);
if (!recipe_id) {
c->Message(Chat::White, "Usage: #enablerecipe [Recipe ID]");
return;
}
c->Message(
Chat::White,
fmt::format(
"Recipe ID {} {} enabled.",
recipe_id,
(
content_db.EnableRecipe(recipe_id) ?
"successfully" :
"failed to be"
)
).c_str()
);
}