fix weekly BR dedup + add /resend-weekly-br dev command
Per-squadron WeeklyBR reports are distinct from the global wildcard report and should always send even when both point at the same channel. Removed the dedup block that was silently dropping squadron-specific embeds whenever the channel matched the wildcard channel. Adds /resend-weekly-br (dev-only) to force-resend the most recently ended BR window to all configured channels, clearing the idempotency marker first. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -990,6 +990,55 @@ async def test_weekly_br_error(interaction, error):
|
||||
await permission_fail(interaction, error)
|
||||
|
||||
|
||||
@is_blacklisted()
|
||||
@bot.tree.command(
|
||||
name="resend-weekly-br",
|
||||
description="[DEV] Force-resend the most recently ended Weekly BR Report to all configured channels",
|
||||
)
|
||||
async def resend_weekly_br(interaction: discord.Interaction):
|
||||
"""Clears the idempotency marker and re-dispatches the last BR window."""
|
||||
from .task_executors import execute_weekly_br_report_task, WEEKLY_BR_MARKER_PATH
|
||||
|
||||
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=True)
|
||||
|
||||
window = _pick_test_br_window()
|
||||
if window is None:
|
||||
await interaction.followup.send("Could not pick a BR window from SCHEDULE.json.", ephemeral=True)
|
||||
return
|
||||
|
||||
# Clear the idempotency marker so execute_weekly_br_report_task will proceed.
|
||||
try:
|
||||
WEEKLY_BR_MARKER_PATH.unlink(missing_ok=True)
|
||||
except Exception as e:
|
||||
await interaction.followup.send(f"Failed to clear marker file: {e}", ephemeral=True)
|
||||
return
|
||||
|
||||
start_ts = int(window["start"])
|
||||
end_ts = int(window["end"])
|
||||
await interaction.followup.send(
|
||||
f"Resending **{window['max_br']} BR** window "
|
||||
f"(<t:{start_ts}:D> → <t:{end_ts}:D>) to all configured channels…",
|
||||
ephemeral=True,
|
||||
)
|
||||
|
||||
try:
|
||||
await execute_weekly_br_report_task(window)
|
||||
await interaction.followup.send("✅ Resend complete.", ephemeral=True)
|
||||
except Exception as e:
|
||||
logging.error("[RESEND-WBR] Error: %s", e)
|
||||
await interaction.followup.send(f"❌ Resend failed: {e}", ephemeral=True)
|
||||
|
||||
|
||||
@resend_weekly_br.error
|
||||
async def resend_weekly_br_error(interaction, error):
|
||||
logging.error("[RESEND-WBR] Unhandled error: %s", error)
|
||||
|
||||
|
||||
async def _diagnose_perms_logic(interaction: discord.Interaction, target_channel=None):
|
||||
"""Core logic for autolog diagnostics. Called from the diagnose channel select."""
|
||||
await interaction.response.defer(ephemeral=True)
|
||||
|
||||
@@ -2039,13 +2039,8 @@ async def execute_weekly_br_report_task(window: Dict[str, Any]) -> None:
|
||||
if wildcard_channel_id is None and not squadron_channels:
|
||||
continue
|
||||
|
||||
# Dedupe: drop per-squadron entries that target the same channel as wildcard.
|
||||
if wildcard_channel_id is not None:
|
||||
squadron_channels = [
|
||||
(cid, pref_key, info)
|
||||
for cid, pref_key, info in squadron_channels
|
||||
if cid != wildcard_channel_id
|
||||
]
|
||||
# Per-squadron reports are distinct from the wildcard report and may
|
||||
# legitimately share the same channel — both should be sent.
|
||||
|
||||
# Resolve guild language once per guild
|
||||
guild_features = await load_features(guild_id)
|
||||
|
||||
Reference in New Issue
Block a user