Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion workspaces/post-leetcode-potd-to-discord/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ To use:
<!-- prettier-ignore-start -->
<!-- The two spaces at the end of the next line are intentional and necessary for rendering a single line break. -->

> New LeetCode problem of the day: [1460. Make Two Arrays Equal by Reversing Subarrays](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-subarrays/) (marked Easy) ✨
> New LeetCode problem of the day: 🥦 [1460. Make Two Arrays Equal by Reversing Subarrays](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-subarrays/) 🥦
>
> ##### Problem due: ⏳ in 20 hours ⏳

Expand Down
12 changes: 11 additions & 1 deletion workspaces/post-leetcode-potd-to-discord/src/getPotdMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@ import { yearMonthDayToTimestampInSeconds } from "@code-chronicles/util/yearMont

import { formatTimestampForDiscord } from "./formatTimestampForDiscord.ts";

const EMOJI_FOR_DIFFICULTY: Record<
ActiveDailyCodingChallengeQuestion["question"]["difficulty"],
string
> = {
Easy: "🥦",
Medium: "🥕",
Hard: "🌶️",
};

// TODO: jest tests
export function getPotdMessage({
date,
question: { difficulty, questionFrontendId, title, titleSlug },
}: ActiveDailyCodingChallengeQuestion): string {
const link = `https://leetcode.com/problems/${titleSlug}/`;
const emoji = EMOJI_FOR_DIFFICULTY[difficulty];

return dedent`
New LeetCode problem of the day: [${questionFrontendId}. ${title}](${link}) (marked ${difficulty}) ✨
New LeetCode problem of the day: ${emoji} [${questionFrontendId}. ${title}](${link}) ${emoji}

-# Problem due: ⏳ **${formatTimestampForDiscord(yearMonthDayToTimestampInSeconds(date) + SEC_IN_DAY, "R")}** ⏳
`;
Expand Down
Loading