feat(tally): friendlier option labels + dev-tally only counts matching target (#1340)

Rename /tally-claim and /tally-transfer options to username/squadron with
clearer descriptions. Fix /dev-tally to only apply a win/loss when the
passed username/squadron actually matches what the VC is tracking, instead
of bumping any active tally.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
NotSoToothless
2026-06-19 01:27:08 -07:00
committed by GitHub
parent 9222f7c53f
commit db7c546a24
2 changed files with 40 additions and 18 deletions
+38 -16
View File
@@ -4261,11 +4261,11 @@ def _invoker_voice_channel(interaction: discord.Interaction):
),
)
@app_commands.describe(
ign=command_locale("The player IGN to track", "commands.tally.ign"),
squadron_short=command_locale("The squadron short name to track", "commands.tally.squadron_short"),
username=command_locale("Username", "commands.tally.username"),
squadron=command_locale("Squadron Name (like DSPL)", "commands.tally.squadron"),
)
@discord.app_commands.autocomplete(ign=player_autocomplete, squadron_short=squadron_autocomplete)
async def tally_claim(interaction: discord.Interaction, ign: str = "", squadron_short: str = ""):
@discord.app_commands.autocomplete(username=player_autocomplete, squadron=squadron_autocomplete)
async def tally_claim(interaction: discord.Interaction, username: str = "", squadron: str = ""):
lang = await guild_lang(interaction.guild.id) if interaction.guild else "en"
if not interaction.guild_id or not await is_guild_entitled(interaction.guild_id):
await interaction.response.send_message(t(lang, "commands.tally.premium_required"), ephemeral=True)
@@ -4274,9 +4274,9 @@ async def tally_claim(interaction: discord.Interaction, ign: str = "", squadron_
if vc is None:
await interaction.response.send_message(t(lang, "commands.tally.not_in_vc"), ephemeral=True)
return
ign = ign.strip()
squadron_short = squadron_short.strip()
if bool(ign) == bool(squadron_short): # neither or both
username = username.strip()
squadron = squadron.strip()
if bool(username) == bool(squadron): # neither or both
await interaction.response.send_message(t(lang, "commands.tally.need_one_input"), ephemeral=True)
return
@@ -4288,10 +4288,10 @@ async def tally_claim(interaction: discord.Interaction, ign: str = "", squadron_
)
return
if ign:
mode, target, display = "player", ign, ign
if username:
mode, target, display = "player", username, username
else:
mode, target, display = "squadron", squadron_short, squadron_short
mode, target, display = "squadron", squadron, squadron
tly = tally.claim(interaction.guild_id, vc.id, mode, target, display, interaction.user.id)
await tally.push_status(tly)
@@ -4307,9 +4307,9 @@ async def tally_claim(interaction: discord.Interaction, ign: str = "", squadron_
"commands.tally.description_transfer",
),
)
@app_commands.describe(ign=command_locale("The player IGN to track", "commands.tally.ign"))
@discord.app_commands.autocomplete(ign=player_autocomplete)
async def tally_transfer(interaction: discord.Interaction, ign: str):
@app_commands.describe(username=command_locale("Username", "commands.tally.username"))
@discord.app_commands.autocomplete(username=player_autocomplete)
async def tally_transfer(interaction: discord.Interaction, username: str):
lang = await guild_lang(interaction.guild.id) if interaction.guild else "en"
if not interaction.guild_id or not await is_guild_entitled(interaction.guild_id):
await interaction.response.send_message(t(lang, "commands.tally.premium_required"), ephemeral=True)
@@ -4323,8 +4323,8 @@ async def tally_transfer(interaction: discord.Interaction, ign: str):
t(lang, "commands.tally.no_active", channel=vc.name), ephemeral=True
)
return
ign = ign.strip()
tly = tally.transfer(interaction.guild_id, vc.id, ign, ign)
username = username.strip()
tly = tally.transfer(interaction.guild_id, vc.id, username, username)
if tly is None:
await interaction.response.send_message(
t(lang, "commands.tally.no_active", channel=vc.name), ephemeral=True
@@ -4332,7 +4332,7 @@ async def tally_transfer(interaction: discord.Interaction, ign: str):
return
await tally.push_status(tly)
await interaction.response.send_message(
t(lang, "commands.tally.transferred", channel=vc.name, target=ign,
t(lang, "commands.tally.transferred", channel=vc.name, target=username,
base=f"{tly.wins}W-{tly.losses}L"),
ephemeral=True,
)
@@ -4402,6 +4402,28 @@ async def dev_tally(interaction: discord.Interaction, result: app_commands.Choic
if not interaction.guild_id:
await interaction.response.send_message(t(lang, "commands.tally.not_in_vc"), ephemeral=True)
return
active = tally.get(interaction.guild_id, vc.id)
if active is None:
await interaction.response.send_message(
t(lang, "commands.tally.no_active", channel=vc.name), ephemeral=True
)
return
# Only attribute the result if the argument matches what this VC tracks —
# a player arg must match a player-mode tally's target; a squadron arg must
# match a squadron-mode tally's target (tag-insensitive). Mirrors how a real
# finished game only counts when the tracked entity actually played.
if username:
matches = active.mode == "player" and active.target.strip().lower() == username.lower()
else:
matches = active.mode == "squadron" and \
tally.strip_tag(active.target).lower() == tally.strip_tag(squadron).lower()
if not matches:
await interaction.response.send_message(
f"This VC is tracking the {active.mode} **{active.display_target}** — "
f"**{username or squadron}** doesn't match it, so nothing was recorded.",
ephemeral=True,
)
return
tly = tally.apply_manual_result(interaction.guild_id, vc.id, result.value)
if tly is None:
await interaction.response.send_message(
+2 -2
View File
@@ -852,8 +852,8 @@
"description_claim": "Track a live SQB scoreline on your current voice channel",
"description_transfer": "Transfer the active voice-channel tally to a different player",
"description_wipe": "Clear the active tally on your current voice channel",
"ign": "The player IGN to track",
"squadron_short": "The squadron short name to track",
"username": "Username",
"squadron": "Squadron Name (like DSPL)",
"result_win": "Win",
"result_loss": "Loss",
"result_draw": "Draw",