Skip to content

Commit 547deb7

Browse files
committed
style: refresh all embeds with consistent author, footer, timestamps, colors, and progress bars
1 parent e9d20c4 commit 547deb7

1 file changed

Lines changed: 52 additions & 26 deletions

File tree

cogs/ranked.py

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,15 @@ async def update_ranked_display(self):
596596
)
597597

598598
for qdata in game_queues.values():
599-
if qdata._queue.qsize() > 0:
600-
embed.add_field(name=qdata.full_game_name, value=f"*{qdata._queue.qsize()}/{qdata.alliance_size * 2}*"
601-
f" players in queue", inline=False)
599+
queue_size = qdata._queue.qsize()
600+
if queue_size > 0:
601+
needed = qdata.alliance_size * 2
602+
progress = "██" * queue_size + "░░" * (needed - queue_size)
603+
embed.add_field(
604+
name=qdata.full_game_name,
605+
value=f"({queue_size}/{needed})\n`{progress}`",
606+
inline=False
607+
)
602608

603609
# Add footer with helpful information
604610
embed.set_footer(text="Use /queuevoting to join a vote queue • Use /queuestandard to join a traditional queue • Use /leaveall to leave a queue")
@@ -999,25 +1005,30 @@ async def move_player(player, channel):
9991005
[f"🟦{p.mention} `{blue_elos[i]:.0f}`" for i, p in enumerate(blue_players)])
10001006

10011007
# Build both embeds
1008+
now = datetime.now(timezone.utc)
10021009
server_info_embed = discord.Embed(
10031010
color=0x34dceb,
1004-
title=f"Server Information for {match.full_game_name}",
1005-
description=f"Server 'Ranked{match.api_short}' started with password **{match.server_password}**\n"
1006-
f"|| IP: {ip} Port: {match.server_port} ||"
1011+
title="Server Information",
1012+
description=f"Server `Ranked{match.api_short}` started with password **{match.server_password}**\n"
1013+
f"|| IP: {ip} Port: {match.server_port} ||",
1014+
timestamp=now
10071015
)
1008-
server_info_embed.set_thumbnail(url=match.game_icon)
1009-
server_info_embed.add_field(name=f'RED (Avg: {avg_red_elo:.0f})', value=red_field, inline=True)
1010-
server_info_embed.add_field(name=f'BLUE (Avg: {avg_blue_elo:.0f})', value=blue_field, inline=True)
1016+
server_info_embed.set_author(name=match.full_game_name, icon_url=match.game_icon)
1017+
server_info_embed.add_field(name=f'🟥 RED (Avg: {avg_red_elo:.0f})', value=red_field, inline=True)
1018+
server_info_embed.add_field(name=f'🟦 BLUE (Avg: {avg_blue_elo:.0f})', value=blue_field, inline=True)
1019+
server_info_embed.set_footer(text="xRC Sim Ranked", icon_url=XRC_SIM_LOGO_URL)
10111020

10121021
teams_embed = discord.Embed(
10131022
color=0x34dceb,
1014-
title=f"Teams have been picked for {match.full_game_name}!",
1015-
description=f"Server information has been posted in {password_channel.mention}\n"
1016-
f"[Adjust Display Name](https://secondrobotics.org/user/settings/) | [Leaderboard](https://secondrobotics.org/ranked/{match.api_short})"
1023+
title="Teams Picked!",
1024+
description=f"Server info posted in {password_channel.mention}\n"
1025+
f"[Adjust Display Name](https://secondrobotics.org/user/settings/) | [Leaderboard](https://secondrobotics.org/ranked/{match.api_short})",
1026+
timestamp=now
10171027
)
1018-
teams_embed.set_thumbnail(url=match.game_icon)
1019-
teams_embed.add_field(name=f'RED (Avg: {avg_red_elo:.0f})', value=red_field, inline=True)
1020-
teams_embed.add_field(name=f'BLUE (Avg: {avg_blue_elo:.0f})', value=blue_field, inline=True)
1028+
teams_embed.set_author(name=match.full_game_name, icon_url=match.game_icon)
1029+
teams_embed.add_field(name=f'🟥 RED (Avg: {avg_red_elo:.0f})', value=red_field, inline=True)
1030+
teams_embed.add_field(name=f'🟦 BLUE (Avg: {avg_blue_elo:.0f})', value=blue_field, inline=True)
1031+
teams_embed.set_footer(text="xRC Sim Ranked", icon_url=XRC_SIM_LOGO_URL)
10211032

10221033
# Send to both channels in parallel
10231034
await asyncio.gather(
@@ -1087,14 +1098,16 @@ async def _auto_clear_check(self, match: XrcGame, guild: discord.Guild):
10871098
total = len(match.game.red | match.game.blue)
10881099
needed = total // 2 + 1
10891100
embed = discord.Embed(
1090-
title="Match Inactivity",
1101+
title="Match Inactivity",
10911102
description=(
10921103
f"This match has been inactive for 10 minutes.\n"
10931104
f"Vote to clear if the match is not happening.\n"
10941105
f"**{needed}/{total}** votes needed to clear."
10951106
),
1096-
color=discord.Color.orange()
1107+
color=discord.Color.orange(),
1108+
timestamp=datetime.now(timezone.utc)
10971109
)
1110+
embed.set_footer(text="xRC Sim Ranked", icon_url=XRC_SIM_LOGO_URL)
10981111
view = ClearVoteView(self, guild, match)
10991112
try:
11001113
msg = await password_channel.send(
@@ -1828,17 +1841,29 @@ async def submit_score_to_api(self, current_match, red_score, blue_score):
18281841
return None
18291842

18301843
def create_score_embed(self, current_match, red_score, blue_score, response):
1831-
embed = discord.Embed(color=0x34eb3d,
1832-
title=f"[{current_match.full_game_name}] Score submitted | 🟥 {current_match.red_series}-{current_match.blue_series} 🟦 |")
1833-
embed.set_thumbnail(url=current_match.game_icon)
1844+
game_number = len(current_match.game_scores)
1845+
if red_score > blue_score:
1846+
embed_color = discord.Color(0xE74C3C)
1847+
elif blue_score > red_score:
1848+
embed_color = discord.Color(0x3498DB)
1849+
else:
1850+
embed_color = discord.Color(0x95A5A6)
1851+
1852+
embed = discord.Embed(
1853+
color=embed_color,
1854+
title=f"Game {game_number} — 🟥 {current_match.red_series}{current_match.blue_series} 🟦",
1855+
timestamp=datetime.now(timezone.utc)
1856+
)
1857+
embed.set_author(name=current_match.full_game_name, icon_url=current_match.game_icon)
1858+
embed.set_footer(text="xRC Sim Ranked", icon_url=XRC_SIM_LOGO_URL)
18341859

1835-
for color, score in [('red', red_score), ('blue', blue_score)]:
1860+
for side, score in [('red', red_score), ('blue', blue_score)]:
18361861
players = "\n".join(
1837-
f"[{response[f'{color}_display_names'][i]}](https://secondrobotics.org/ranked/{current_match.api_short}/{player['player']}) "
1838-
f"`[{round(player['elo'], 2)}]` ```diff\n{'%+.2f' % (round(response[f'{color}_elo_changes'][i], 3))}\n```"
1839-
for i, player in enumerate(response[f'{color}_player_elos'])
1862+
f"[{response[f'{side}_display_names'][i]}](https://secondrobotics.org/ranked/{current_match.api_short}/{player['player']}) "
1863+
f"`[{round(player['elo'], 2)}]` ```diff\n{'%+.2f' % (round(response[f'{side}_elo_changes'][i], 3))}\n```"
1864+
for i, player in enumerate(response[f'{side}_player_elos'])
18401865
)
1841-
embed.add_field(name=f'{color.upper()} {"🟥" if color == "red" else "🟦"} ({score})',
1866+
embed.add_field(name=f'{"🟥 RED" if side == "red" else "🟦 BLUE"} ({score})',
18421867
value=players,
18431868
inline=True)
18441869
logger.info(f"embed created at {current_match.red_series}-{current_match.blue_series}")
@@ -1856,7 +1881,8 @@ def create_series_summary_embed(self, match: XrcGame) -> discord.Embed:
18561881
color=color,
18571882
timestamp=datetime.now(timezone.utc),
18581883
)
1859-
embed.set_thumbnail(url=match.game_icon)
1884+
embed.set_author(name=match.full_game_name, icon_url=match.game_icon)
1885+
embed.set_footer(text="xRC Sim Ranked", icon_url=XRC_SIM_LOGO_URL)
18601886

18611887
if match.game_scores:
18621888
lines = []

0 commit comments

Comments
 (0)