Skip to content

Commit 57b0d04

Browse files
authored
Simplify PotD bot messages (#490)
The flavor text for difficulty doesn't seem to have been particularly popular so simplifying it. Also, closes #446.
1 parent b02e5c4 commit 57b0d04

File tree

4 files changed

+14
-26
lines changed

4 files changed

+14
-26
lines changed

workspaces/post-leetcode-potd-to-discord/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ To use:
5959
<!-- prettier-ignore-start -->
6060
<!-- The two spaces at the end of the next line are intentional and necessary for rendering a single line break. -->
6161

62-
> ✨ 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/)
63-
> It's marked easy, so don't overthink it!
62+
> ✨ 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) ✨
63+
>
64+
> ##### Problem due: ⏳ in 20 hours ⏳
65+
66+
Note that the "in 20 hours" is a [Discord relative timestamp](https://discord.com/developers/docs/reference#message-formatting-timestamp-styles) so it will remain up-to-date as time passes.
6467

6568
<!-- prettier-ignore-end -->
6669

workspaces/post-leetcode-potd-to-discord/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@code-chronicles/leetcode-api": "workspace:*",
2626
"@code-chronicles/util": "workspace:*",
2727
"bufferutil": "4.0.8",
28+
"dedent": "1.5.3",
2829
"discord.js": "14.15.3",
2930
"invariant": "2.2.4",
3031
"utf-8-validate": "6.0.4",
Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,21 @@
1+
import dedent from "dedent";
2+
13
import type { ActiveDailyCodingChallengeQuestion } from "@code-chronicles/leetcode-api/active-daily-coding-challenge-question";
24
import { SEC_IN_DAY } from "@code-chronicles/util/timeConstants";
35
import { yearMonthDayToTimestampInSeconds } from "@code-chronicles/util/yearMonthDayToTimestampInSeconds";
46

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

9+
// TODO: jest tests
710
export function getPotdMessage({
811
date,
912
question: { difficulty, questionFrontendId, title, titleSlug },
1013
}: ActiveDailyCodingChallengeQuestion): string {
1114
const link = `https://leetcode.com/problems/${titleSlug}/`;
12-
const sentences = [
13-
`✨ New LeetCode problem of the day: [${questionFrontendId}. ${title}](${link}) ✨`,
14-
];
15-
16-
switch (difficulty) {
17-
case "Easy": {
18-
sentences.push("It's marked easy, so don't overthink it!");
19-
break;
20-
}
21-
case "Medium": {
22-
sentences.push("It's marked medium, so nothing too scary.");
23-
break;
24-
}
25-
case "Hard": {
26-
sentences.push(
27-
"It's marked hard, but that's just a label. Ask for help here if you need it!",
28-
);
29-
break;
30-
}
31-
}
3215

33-
sentences.push(
34-
`\n-# Problem due - ⏳ ****${formatTimestampForDiscord(yearMonthDayToTimestampInSeconds(date) + SEC_IN_DAY, "R")}**** ⏳`,
35-
);
16+
return dedent`
17+
✨ New LeetCode problem of the day: [${questionFrontendId}. ${title}](${link}) (marked ${difficulty}) ✨
3618
37-
return sentences.join("\n");
19+
-# Problem due: ⏳ **${formatTimestampForDiscord(yearMonthDayToTimestampInSeconds(date) + SEC_IN_DAY, "R")}** ⏳
20+
`;
3821
}

yarn.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)