From 95bc5c559c8f773fab66b16e4a563899dbd6c9e2 Mon Sep 17 00:00:00 2001 From: supinic Date: Sun, 8 Dec 2024 16:32:11 +0100 Subject: [PATCH] `formula1` added backup starter data for 2025 season --- commands/formula1/api-wrapper.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/commands/formula1/api-wrapper.js b/commands/formula1/api-wrapper.js index 0e300e97e..b026be53b 100644 --- a/commands/formula1/api-wrapper.js +++ b/commands/formula1/api-wrapper.js @@ -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({ @@ -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!`