Skip to content

Commit

Permalink
formula1 added backup starter data for 2025 season
Browse files Browse the repository at this point in the history
  • Loading branch information
Supinic committed Dec 8, 2024
1 parent 887c76b commit 95bc5c5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions commands/formula1/api-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ const sessionNames = {
Sprint: "Sprint race"
};

const BACKUP_RACE_DATA = {
2025: {
name: "Australian Grand Prix",
date: "2025-03-16"
}
};

let ergastGotInstance;
const ergastGot = (...args) => {
ergastGotInstance ??= sb.Got.get("GenericAPI").extend({
Expand Down Expand Up @@ -129,6 +136,20 @@ const fetchNextRaceDetail = async (context) => {
const year = new sb.Date().year;
const race = await fetchRace(year, "current");
if (!race) {
const nextYear = year + 1;
const backupRace = BACKUP_RACE_DATA[nextYear];
if (backupRace) {
const delta = sb.Utils.timeDelta(new sb.Date(backupRace.date));
return {
success: true,
reply: sb.Utils.tag.trim `
This year's season is finished.
The first race of next year's season is ${backupRace.name},
taking place ${delta}.
`
};
}

return {
success: false,
reply: `No next F1 race is currently scheduled!`
Expand Down

0 comments on commit 95bc5c5

Please sign in to comment.