From 2d5adfcbe0d23cb21f8d3a807d3993ac16da6b84 Mon Sep 17 00:00:00 2001 From: NotSoToothless <67082114+FURRO404@users.noreply.github.com> Date: Thu, 21 May 2026 23:22:10 -0700 Subject: [PATCH] fix leave alarm (#1265) --- BOT/task_executors.py | 12 ++++++++++-- BOT/utils.py | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/BOT/task_executors.py b/BOT/task_executors.py index f8c1086..a7ce51e 100644 --- a/BOT/task_executors.py +++ b/BOT/task_executors.py @@ -1138,6 +1138,8 @@ async def execute_leave_alarm_task(): tier = await get_guild_tier(guild_id) allowed_points = allowed_pref_keys_for(preferences, tier, "Points") + allowed_leave = allowed_pref_keys_for(preferences, tier, "Leave") + allowed_for_leave = allowed_points | allowed_leave for pref_key, squad_prefs in preferences.items(): if not isinstance(squad_prefs, dict): @@ -1148,8 +1150,9 @@ async def execute_leave_alarm_task(): points_chan = squad_prefs.get("Points") if not leave_chan and not points_chan: continue - # Respect the Points tier cap — identical gate used by execute_points_alarm_task. - if tier_enforcement_active() and pref_key not in allowed_points: + # Respect the tier cap — squadrons must be within either the Points + # or Leave cap to receive leave notifications. + if tier_enforcement_active() and pref_key not in allowed_for_leave: continue resolved = await resolve_pref_key(pref_key, squad_prefs) target_name = resolved["long_name"] if resolved and resolved.get("long_name") else pref_key @@ -1232,6 +1235,11 @@ async def execute_leave_alarm_task(): for guild_id, channel_id in guild_channels: channel = bot.get_channel(channel_id) + if not channel: + try: + channel = await bot.fetch_channel(channel_id) + except (discord.NotFound, discord.Forbidden): + channel = None if not channel: logging.error("(LEAVE) Channel %s not found in guild %s", channel_id, guild_id) continue diff --git a/BOT/utils.py b/BOT/utils.py index 0dbe0ae..5f47ca5 100644 --- a/BOT/utils.py +++ b/BOT/utils.py @@ -157,9 +157,9 @@ TIER_ENFORCEMENT_TS: int = 1778107232 Tier = Literal["standard", "pro", "max"] TIER_NOTIF_CAPS: Dict[str, Dict[str, Optional[int]]] = { - "standard": {"Logs": 10, "Points": 10}, - "pro": {"Logs": 25, "Points": 25}, - "max": {"Logs": None, "Points": None}, + "standard": {"Logs": 10, "Points": 10, "Leave": 10}, + "pro": {"Logs": 25, "Points": 25, "Leave": 25}, + "max": {"Logs": None, "Points": None, "Leave": None}, } TIER_ALLOWS_WILDCARDS: Dict[str, bool] = {