Skip to content

Commit 065ae13

Browse files
show a list of changes for the 2025 season, get rid of the global leaderboard
1 parent 9557918 commit 065ae13

File tree

5 files changed

+86
-28
lines changed

5 files changed

+86
-28
lines changed

bot/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ class Colours:
223223
python_yellow = 0xFFD43B
224224
grass_green = 0x66FF00
225225
gold = 0xE6C200
226+
aoc_violet = 0x43439D
226227

227228

228229
# Git SHA for Sentry

bot/exts/advent_of_code/_cog.py

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
from datetime import UTC, datetime, timedelta
33
from pathlib import Path
4+
from typing import Literal
45

56
import arrow
67
import discord
@@ -52,8 +53,13 @@ def __init__(self, bot: SirRobin):
5253
self._base_url = f"https://adventofcode.com/{AocConfig.year}"
5354
self.global_leaderboard_url = f"https://adventofcode.com/{AocConfig.year}/leaderboard"
5455

55-
self.about_aoc_filepath = Path("./bot/exts/advent_of_code/about.json")
56-
self.cached_about_aoc = self._build_about_embed()
56+
self.aoc_files = Path("./bot/exts/advent_of_code/")
57+
self.cached_about_aoc = self._build_embed_from_json("about")
58+
self.cached_changes = self._build_embed_from_json("changes_2025")
59+
self.cached_no_global = self._build_embed_from_json(
60+
"changes_2025", only_field="What happened to the global leaderboard?"
61+
)
62+
self.cached_no_global.colour = Colours.soft_red
5763

5864
self.scheduler = scheduling.Scheduler(self.__class__.__name__)
5965

@@ -410,22 +416,27 @@ async def aoc_leaderboard(self, ctx: commands.Context, *, aoc_name: str | None =
410416
await ctx.send(content=f"{header}\n\n{table}", embed=info_embed)
411417
return
412418

419+
@in_month(Month.DECEMBER, Month.JANUARY, Month.FEBRUARY)
420+
@adventofcode_group.command(
421+
name="changes",
422+
brief="Frequently Asked Questions about Advent of Code changes in 2025",
423+
)
424+
@in_whitelist(channels=AOC_WHITELIST_RESTRICTED, redirect=AOC_REDIRECT)
425+
async def aoc_changes(self, ctx: commands.Context) -> None:
426+
"""Get answers to frequently asked questions about Advent of Code changes in 2025."""
427+
await ctx.send(embed=self.cached_changes)
428+
413429
@in_month(Month.DECEMBER, Month.JANUARY, Month.FEBRUARY)
414430
@adventofcode_group.command(
415431
name="global",
416432
aliases=("globalboard", "gb"),
433+
hidden=True, # Global leaderboard no longer exists
417434
brief="Get a link to the global leaderboard",
418435
)
419436
@in_whitelist(channels=AOC_WHITELIST_RESTRICTED, redirect=AOC_REDIRECT)
420437
async def aoc_global_leaderboard(self, ctx: commands.Context) -> None:
421-
"""Get a link to the global Advent of Code leaderboard."""
422-
url = self.global_leaderboard_url
423-
global_leaderboard = discord.Embed(
424-
title="Advent of Code — Global Leaderboard",
425-
description=f"You can find the global leaderboard [here]({url})."
426-
)
427-
global_leaderboard.set_thumbnail(url=_helpers.AOC_EMBED_THUMBNAIL)
428-
await ctx.send(embed=global_leaderboard)
438+
# Same behaviour as aoc changes, but change the title to "where's the global leaderboard"
439+
await ctx.send(embed=self.cached_no_global)
429440

430441
@in_month(Month.DECEMBER, Month.JANUARY, Month.FEBRUARY)
431442
@adventofcode_group.command(
@@ -479,19 +490,39 @@ async def refresh_leaderboard(self, ctx: commands.Context) -> None:
479490
else:
480491
await ctx.send("\N{OK Hand Sign} Refreshed leaderboard cache!")
481492

482-
def _build_about_embed(self) -> discord.Embed:
493+
def _build_embed_from_json(
494+
self, file_type: Literal["about","changes_2025"], *, only_field: str | None = None
495+
) -> discord.Embed:
483496
"""Build and return the informational "About AoC" embed from the resources file."""
484-
embed_fields = json.loads(self.about_aoc_filepath.read_text("utf8"))
497+
if file_type == "about":
498+
filepath = self.aoc_files / "about.json"
499+
title = "Advent of Code"
500+
url = self._base_url
501+
colour = Colours.soft_green
502+
503+
elif file_type == "changes_2025":
504+
filepath = self.aoc_files / "changes_2025.json"
505+
title = "2025 Changes"
506+
url = None
507+
colour = Colours.aoc_violet
508+
else:
509+
raise ValueError("file_type must be either 'about' or 'changes_2025'")
485510

486-
about_embed = discord.Embed(
487-
title=self._base_url,
488-
colour=Colours.soft_green,
489-
url=self._base_url,
490-
timestamp=datetime.now(tz=UTC)
491-
)
492-
about_embed.set_author(name="Advent of Code", url=self._base_url)
493-
for field in embed_fields:
494-
about_embed.add_field(**field)
511+
embed = discord.Embed(title=title, url=url, colour=colour, timestamp=datetime.now(tz=UTC))
512+
513+
embed_fields = json.loads(filepath.read_text("utf8"))
514+
515+
if only_field:
516+
embed_fields = [field for field in embed_fields if field["name"] == only_field]
517+
if not embed_fields:
518+
raise ValueError(f"No field named '{only_field}' found in {file_type}.json")
519+
embed.title = only_field
520+
embed.description = embed_fields[0]["value"]
521+
else:
522+
for field in embed_fields:
523+
embed.add_field(**field)
524+
525+
embed.set_author(name="Advent of Code", url=self._base_url)
526+
embed.set_footer(text="Last Updated")
495527

496-
about_embed.set_footer(text="Last Updated")
497-
return about_embed
528+
return embed

bot/exts/advent_of_code/_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def _format_leaderboard(leaderboard: dict[str, dict], self_placement_name: str |
188188
raise commands.BadArgument(
189189
"Sorry, your profile does not exist in this leaderboard."
190190
"\n\n"
191-
"To join our leaderboard, run the command `/aoc join`."
191+
"To join our leaderboard, run the command </aoc join:1312458389388787853>."
192192
" If you've joined recently, please wait up to 30 minutes for our leaderboard to refresh."
193193
)
194194
return "\n".join(leaderboard_lines)

bot/exts/advent_of_code/about.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
"inline": true
1616
},
1717
{
18-
"name": "How does scoring work?",
19-
"value": "For the [global leaderboard](https://adventofcode.com/leaderboard), the first person to get a star first gets 100 points, the second person gets 99 points, and so on down to 1 point at 100th place.\n\nFor private leaderboards, the first person to get a star gets N points, where N is the number of people on the leaderboard. The second person to get the star gets N-1 points and so on and so forth.",
18+
"name": "Is it a competition?",
19+
"value": "In prior years, AoC had a global leaderboard which ranked all participants. Beginning in 2025, the only leaderboards available are private leaderboards. In these private leaderboards, the first person to get a star gets N points, where N is the number of people on the leaderboard. The second person to get the star gets N-1 points and so on and so forth.",
2020
"inline": false
2121
},
2222
{
23-
"name": "Join our private leaderboard!",
24-
"value": "Come join the Python Discord private leaderboard and compete against other people in the community! Get the join code using `.aoc join` and visit the [private leaderboard page](https://adventofcode.com/leaderboard/private) to join our leaderboard.",
23+
"name": "Join our leaderboard!",
24+
"value": "Come join the Python Discord leaderboard and compete against other people in the community! Get the join code using </aoc join:1312458389388787853> and visit the [leaderboard page](https://adventofcode.com/leaderboard/private) to join our leaderboard.",
2525
"inline": false
2626
}
2727
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[
2+
{
3+
"name": "What changed in Advent of Code 2025?",
4+
"value": "In 2025, Advent of Code made significant changes to its leaderboard system. The global leaderboard was removed, and now only private leaderboards are available. This change aims to create a more inclusive and supportive environment for all participants."
5+
},
6+
{
7+
"name": "Why did the number of days per event change?",
8+
"value": "[Eric needed a break.](https://hachyderm.io/@ericwastl/115415473413415697) The puzzles still start on December 1st so that the day numbers make sense (Day 1 = Dec 1), and puzzles come out every day (ending mid-December).",
9+
"inline": false
10+
},
11+
{
12+
"name": "What happened to the global leaderboard?",
13+
"value": "The global leaderboard has been removed starting in 2025 due to DDoS attacks and other issues. Private leaderboards are now the only option for competition.\nYou can join the Python Discord leaderboard with </aoc join:1312458389388787853>.",
14+
"inline": false
15+
},
16+
{
17+
"name": "Is there still a way to compete with others?",
18+
"value": "We have our own private leaderboard for the Python Discord community! You can join it using the </aoc join:1312458389388787853> command and compete with other members of the community.",
19+
"inline": false
20+
},
21+
{
22+
"name": "Where can I find more information?",
23+
"value": "For more details about the changes in Advent of Code 2025, you can refer to the [official announcement on Reddit](https://www.reddit.com/r/adventofcode/comments/1ocwh04/changes_to_advent_of_code_starting_this_december/) and the [FAQ on the Advent of Code website](https://adventofcode.com/2025/about).",
24+
"inline": false
25+
}
26+
]

0 commit comments

Comments
 (0)