fix weekly br selector (#1249)

This commit is contained in:
NotSoToothless
2026-05-15 02:23:30 -07:00
committed by GitHub
parent 6303285425
commit de78c90033
+6 -9
View File
@@ -857,7 +857,7 @@ async def quick_log_error(interaction, error):
def _pick_test_br_window() -> Optional[Dict[str, Any]]:
"""Return the BR window enclosing now, else the most recently ended one."""
"""Return the most recently ended BR window (mirrors the real scheduled task)."""
schedule_path = Path(__file__).parent / "SCHEDULE.json"
try:
with open(schedule_path, "r", encoding="utf-8") as fp:
@@ -867,27 +867,21 @@ def _pick_test_br_window() -> Optional[Dict[str, Any]]:
return None
now_ts = int(time_module.time())
active = None
most_recent_past = None
for entry in schedule:
try:
s = int(entry["start"])
e = int(entry["end"])
except (KeyError, TypeError, ValueError):
continue
if s <= now_ts <= e:
active = entry
break
if e < now_ts and (most_recent_past is None or e > int(most_recent_past["end"])):
most_recent_past = entry
return active or most_recent_past
return most_recent_past
@is_blacklisted()
@is_admin()
@bot.tree.command(
name="test-weekly-br",
description="[Admin] Preview the Weekly BR Report for the current/most-recent BR window",
description="[DEV] Preview the Weekly BR Report for the current/most-recent BR window",
)
@app_commands.describe(
squadron_name="Optional: also send the per-squadron variant for this squadron",
@@ -909,6 +903,9 @@ async def test_weekly_br(
)
await collect_command_stats(interaction)
if not await is_dev_team(interaction):
await interaction.response.send_message(t("en", "dev.restricted_dev_team"), ephemeral=True)
return
await interaction.response.defer(ephemeral=False)
lang = await guild_lang(interaction.guild.id) if interaction.guild else "en"