feat(Scripts/Commands): default battle id to Wintergrasp when omitted (#26035)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Andrew
2026-05-31 10:10:27 -03:00
committed by GitHub
parent 1b026d2e0b
commit 51f3ebebc0
2 changed files with 25 additions and 6 deletions
@@ -0,0 +1,12 @@
--
-- Update `command` help text for .bf subcommands: #battleid is now optional
-- and defaults to 1 (Wintergrasp) when omitted.
DELETE FROM `command` WHERE `name` IN ('bf start', 'bf stop', 'bf switch', 'bf enable', 'bf timer', 'bf queue');
INSERT INTO `command` (`name`, `security`, `help`) VALUES
('bf start', 3, 'Syntax: .bf start [#battleid]\r\n#battleid is optional and defaults to 1 (Wintergrasp).'),
('bf stop', 3, 'Syntax: .bf stop [#battleid]\r\n#battleid is optional and defaults to 1 (Wintergrasp).'),
('bf switch', 3, 'Syntax: .bf switch [#battleid]\r\n#battleid is optional and defaults to 1 (Wintergrasp).'),
('bf enable', 3, 'Syntax: .bf enable [#battleid]\r\n#battleid is optional and defaults to 1 (Wintergrasp).'),
('bf timer', 3, 'Syntax: .bf timer [#battleid] #timer\r\n#battleid is optional and defaults to 1 (Wintergrasp).\r\n#timer: use a timestring like "1h15m30s".'),
('bf queue', 2, 'Syntax: .bf queue [#battleid]\r\nDisplays all players currently in queue, invited, or actively in war for the specified battlefield.\r\n#battleid is optional and defaults to 1 (Wintergrasp).');
+13 -6
View File
@@ -49,8 +49,9 @@ public:
return commandTable; return commandTable;
} }
static bool HandleBattlefieldStart(ChatHandler* handler, uint32 battleId) static bool HandleBattlefieldStart(ChatHandler* handler, Optional<uint32> battleIdArg)
{ {
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId); Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
if (!bf) if (!bf)
@@ -67,8 +68,9 @@ public:
return true; return true;
} }
static bool HandleBattlefieldEnd(ChatHandler* handler, uint32 battleId) static bool HandleBattlefieldEnd(ChatHandler* handler, Optional<uint32> battleIdArg)
{ {
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId); Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
if (!bf) if (!bf)
@@ -85,8 +87,9 @@ public:
return true; return true;
} }
static bool HandleBattlefieldEnable(ChatHandler* handler, uint32 battleId) static bool HandleBattlefieldEnable(ChatHandler* handler, Optional<uint32> battleIdArg)
{ {
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId); Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
if (!bf) if (!bf)
@@ -113,8 +116,9 @@ public:
return true; return true;
} }
static bool HandleBattlefieldSwitch(ChatHandler* handler, uint32 battleId) static bool HandleBattlefieldSwitch(ChatHandler* handler, Optional<uint32> battleIdArg)
{ {
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId); Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
if (!bf) if (!bf)
@@ -131,13 +135,15 @@ public:
return true; return true;
} }
static bool HandleBattlefieldTimer(ChatHandler* handler, uint32 battleId, std::string timeStr) static bool HandleBattlefieldTimer(ChatHandler* handler, Optional<uint32> battleIdArg, std::string timeStr)
{ {
if (timeStr.empty()) if (timeStr.empty())
{ {
return false; return false;
} }
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
if (Acore::StringTo<int32>(timeStr).value_or(0) < 0) if (Acore::StringTo<int32>(timeStr).value_or(0) < 0)
{ {
handler->SendErrorMessage(LANG_BAD_VALUE); handler->SendErrorMessage(LANG_BAD_VALUE);
@@ -173,8 +179,9 @@ public:
return true; return true;
} }
static bool HandleBattlefieldQueue(ChatHandler* handler, uint32 battleId) static bool HandleBattlefieldQueue(ChatHandler* handler, Optional<uint32> battleIdArg)
{ {
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId); Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
if (!bf) if (!bf)