fix leave alarm (#1265)
This commit is contained in:
+10
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user