Skip to content

Commit

Permalink
embed: add footer text
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Oct 3, 2024
1 parent a41fab2 commit 933acc4
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions lib/api/dailies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ export async function executeDailyWebhook(
: null;

// Format the webhook embed.
const season = syncedSeason ?? storedSeason;
if (season === null) {
throw new Error("Season not found.");
}

const embeds = makeDailyWebhookEmbeds({
question,
questionDate,
season: syncedSeason ?? storedSeason,
season,
});

// Execute the webhook.
Expand Down Expand Up @@ -83,7 +88,7 @@ export interface DailyWebhookOptions {
/**
* season is the season to recap.
*/
season: api.Season | null;
season: api.Season;
}

/**
Expand Down Expand Up @@ -114,19 +119,20 @@ export function makeDailyWebhookEmbeds(
value: "[See more…](https://acmcsuf.com/lc-dailies-handbook)",
},
],
footer: {
text: `Share: https://acmcsuf.com/lc-dailies/${options.season.id}`,
icon_url: "https://acmcsuf.com/favicon.ico",
},
};

if (options.season) {
embed.fields?.push({
name: `Leaderboard for week of ${options.season.start_date}`,
value: [
"```",
leaderboard.formatScores(options.season),
"```",
`View the leaderboard on [acmcsuf.com/lc-dailies/${options.season.id}](https://acmcsuf.com/lc-dailies/${options.season.id})!`,
].join("\n"),
});
}
embed.fields?.push({
name: `Leaderboard for week of ${options.season.start_date}`,
value: [
"```",
leaderboard.formatScores(options.season),
"```",
].join("\n"),
});

return [embed];
}
Expand Down

0 comments on commit 933acc4

Please sign in to comment.