add leave option and wire up (#1264)

This commit is contained in:
NotSoToothless
2026-05-19 22:24:03 -07:00
committed by GitHub
parent b36886425b
commit cd909bc858
13 changed files with 43 additions and 17 deletions
+10 -6
View File
@@ -689,14 +689,15 @@ async def comp_perm_error(interaction, error):
)
@app_commands.describe(
squadron_name=command_locale("The SHORT name of the squadron to monitor", "commands.quick_log.squadron_name"),
type=command_locale("Choose Logs, Points, Leaderboard, Weekly BR, or Both", "commands.quick_log.type")
type=command_locale("Choose Logs, Points, Player Leave, Leaderboard, Weekly BR, or Both", "commands.quick_log.type")
)
@app_commands.choices(type=[
app_commands.Choice(name=command_locale("Logs", "commands.quick_log.choice_logs"), value="Logs"),
app_commands.Choice(name=command_locale("Points", "commands.quick_log.choice_points"), value="Points"),
app_commands.Choice(name=command_locale("Player Leave", "commands.quick_log.choice_player_leave"), value="Leave"),
app_commands.Choice(name=command_locale("Leaderboard", "commands.quick_log.choice_leaderboard"), value="Leaderboard"),
app_commands.Choice(name=command_locale("Weekly BR", "commands.quick_log.choice_weekly_br"), value="WeeklyBR"),
app_commands.Choice(name=command_locale("Both (Logs + Points)", "commands.quick_log.choice_both"), value="Both"),
app_commands.Choice(name=command_locale("Both Logs and Points", "commands.quick_log.choice_both"), value="Both"),
])
@discord.app_commands.autocomplete(squadron_name=squadron_autocomplete)
async def quick_log(
@@ -704,7 +705,7 @@ async def quick_log(
squadron_name: str = "",
type: str = "Logs"
):
"""Set a Logs, Points, Leaderboard, Weekly BR, or Both alarm for a squadron.
"""Set a Logs, Points, Player Leave, Leaderboard, Weekly BR, or Both alarm for a squadron.
Resolves the squadron name, validates the alarm type, writes the channel
preference to the guild's preferences JSON, and confirms with a premium
@@ -714,7 +715,7 @@ async def quick_log(
interaction: The Discord interaction.
squadron_name: Short name of the squadron to monitor (empty = wildcard
for Logs and Weekly BR).
type: Alarm type -- Logs, Points, Leaderboard, Weekly BR, or Both.
type: Alarm type -- Logs, Points, Player Leave, Leaderboard, Weekly BR, or Both.
"""
await collect_command_stats(interaction)
@@ -724,6 +725,7 @@ async def quick_log(
is_leaderboard = type_lower in ("leaderboard", "leaderboards")
is_both = type_lower in ("both", "all")
is_weekly_br = type_lower == "weeklybr"
is_leave = type_lower in ("leave", "player leave", "player_leave")
lang = await guild_lang(interaction.guild.id) if interaction.guild else 'en'
@@ -733,8 +735,10 @@ async def quick_log(
alarm_type = "Both"
elif is_weekly_br:
alarm_type = "WeeklyBR"
elif is_leave:
alarm_type = "Leave"
else:
if type_normalized not in ("Logs", "Points"):
if type_normalized not in ("Logs", "Points", "Leave"):
await interaction.response.send_message(
t(lang, "quick_log.invalid_type"),
ephemeral=True
@@ -772,7 +776,7 @@ async def quick_log(
pref_key = "everything"
display_name = "everything"
else:
# Logs, Points, Both, and Weekly-BR-with-squadron require a name
# Logs, Points, Player Leave, Both, and Weekly-BR-with-squadron require a name
if not squadron_name:
await interaction.followup.send(
t(lang, "quick_log.squadron_required"),
+1
View File
@@ -703,6 +703,7 @@
"type": "Vyberte Logy, Body, Žebříček, Týdenní BR nebo Oba",
"choice_logs": "Logy",
"choice_points": "Body",
"choice_player_leave": "Odchod hráče",
"choice_leaderboard": "Žebříček",
"choice_both": "Obojí (Logy + Body)",
"choice_weekly_br": "Týdenní BR"
+1
View File
@@ -703,6 +703,7 @@
"type": "Wähle Logs, Punkte, Leaderboard, Wöchentlicher BR oder Beide",
"choice_logs": "Logs",
"choice_points": "Punkte",
"choice_player_leave": "Spieler verlässt",
"choice_leaderboard": "Rangliste",
"choice_both": "Beides (Logs + Punkte)",
"choice_weekly_br": "Wöchentlicher BR"
+5 -4
View File
@@ -124,8 +124,8 @@
"remaining_footer_combined": "{user_remaining}/{user_limit} personal · {server_remaining}/{server_limit} server comp lookups remaining this timeslot"
},
"quick_log": {
"invalid_type": "Type can only be set to Logs, Points, Leaderboard, Weekly BR, or Both.",
"squadron_required": "You must provide a squadron name for Logs, Points, or Both alarms.",
"invalid_type": "Type can only be set to Logs, Points, Player Leave, Leaderboard, Weekly BR, or Both.",
"squadron_required": "You must provide a squadron name for Logs, Points, Player Leave, or Both alarms.",
"wildcard_logs_only": "Only Logs can be set to wildcard squadron.",
"squadron_not_resolved": "Squadron `{squadron}` could not be resolved.",
"save_failed": "Failed to save preferences. Please try again later.",
@@ -701,11 +701,12 @@
"quick_log": {
"description": "Quickly set an alarm for this squadron in this channel",
"squadron_name": "The SHORT name of the squadron to monitor",
"type": "Choose Logs, Points, Leaderboard, Weekly BR, or Both",
"type": "Choose Logs, Points, Player Leave, Leaderboard, Weekly BR, or Both",
"choice_logs": "Logs",
"choice_points": "Points",
"choice_player_leave": "Player Leave",
"choice_leaderboard": "Leaderboard",
"choice_both": "Both (Logs + Points)",
"choice_both": "Both Logs and Points",
"choice_weekly_br": "Weekly BR"
},
"sq_info": {
+1
View File
@@ -703,6 +703,7 @@
"type": "Elige Logs, Puntos, Clasificación, BR Semanal o Ambos",
"choice_logs": "Logs",
"choice_points": "Puntos",
"choice_player_leave": "Salida de jugador",
"choice_leaderboard": "Clasificación",
"choice_both": "Ambos (Logs + Puntos)",
"choice_weekly_br": "BR Semanal"
+1
View File
@@ -703,6 +703,7 @@
"type": "Choisissez Logs, Points, Classement, BR Hebdomadaire ou Les deux",
"choice_logs": "Logs",
"choice_points": "Points",
"choice_player_leave": "Départ de joueur",
"choice_leaderboard": "Classement",
"choice_both": "Les deux (Logs + Points)",
"choice_weekly_br": "BR Hebdomadaire"
+1
View File
@@ -703,6 +703,7 @@
"type": "Scegli Log, Punti, Classifica, BR Settimanale o Entrambi",
"choice_logs": "Logs",
"choice_points": "Punti",
"choice_player_leave": "Uscita giocatore",
"choice_leaderboard": "Classifica",
"choice_both": "Entrambi (Logs + Punti)",
"choice_weekly_br": "BR Settimanale"
+1
View File
@@ -703,6 +703,7 @@
"type": "Wybierz Logi, Punkty, Tabela liderów, Tygodniowy BR lub Oba",
"choice_logs": "Logi",
"choice_points": "Punkty",
"choice_player_leave": "Odejście gracza",
"choice_leaderboard": "Ranking",
"choice_both": "Oba (Logi + Punkty)",
"choice_weekly_br": "Tygodniowy BR"
+1
View File
@@ -703,6 +703,7 @@
"type": "Escolha Logs, Pontos, Classificação, BR Semanal ou Ambos",
"choice_logs": "Logs",
"choice_points": "Pontos",
"choice_player_leave": "Saída de jogador",
"choice_leaderboard": "Ranking",
"choice_both": "Ambos (Logs + Pontos)",
"choice_weekly_br": "BR Semanal"
+1
View File
@@ -703,6 +703,7 @@
"type": "Выберите Логи, Очки, Таблица лидеров, Еженедельный BR или Все",
"choice_logs": "Logs",
"choice_points": "Очки",
"choice_player_leave": "Выход игрока",
"choice_leaderboard": "Рейтинг",
"choice_both": "Оба (Logs + Очки)",
"choice_weekly_br": "Еженедельный BR"
+1
View File
@@ -703,6 +703,7 @@
"type": "Оберіть Логи, Очки, Таблиця лідерів, Тижневий BR або Усі",
"choice_logs": "Logs",
"choice_points": "Очки",
"choice_player_leave": "Вихід гравця",
"choice_leaderboard": "Рейтинг",
"choice_both": "Обидва (Logs + Очки)",
"choice_weekly_br": "Тижневий BR"
+1
View File
@@ -704,6 +704,7 @@
"type": "选择 Logs、Points、排行榜、周BR 或 全部",
"choice_logs": "日志",
"choice_points": "分数",
"choice_player_leave": "玩家离队",
"choice_leaderboard": "排行榜",
"choice_both": "两者(日志 + 分数)",
"choice_weekly_br": "周BR"
+18 -7
View File
@@ -1144,19 +1144,30 @@ async def execute_leave_alarm_task():
continue
if str(pref_key).lower() in WILDCARD_KEYS or str(pref_key).lower() == "global":
continue
raw_chan = squad_prefs.get("Leave") or squad_prefs.get("Points")
if not raw_chan:
leave_chan = squad_prefs.get("Leave")
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:
continue
try:
channel_id = int(raw_chan.strip("<#>"))
except Exception:
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
squadron_channels.setdefault(target_name, []).append((guild_id, channel_id))
# Check Leave first, then fallback to Points. If both are present,
# send to both routes (helps staged migrations to the new pref key).
raw_channels = [leave_chan, points_chan]
for raw_chan in raw_channels:
if not raw_chan:
continue
try:
channel_id = int(raw_chan.strip("<#>"))
except Exception:
continue
targets = squadron_channels.setdefault(target_name, [])
target = (guild_id, channel_id)
if target not in targets:
targets.append(target)
if not squadron_channels:
return