-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimpleTaskReportMessage.ts
More file actions
52 lines (48 loc) · 1.57 KB
/
simpleTaskReportMessage.ts
File metadata and controls
52 lines (48 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Item } from "@src/items";
import { DiscordItemMessage } from "@infrastructure/discord";
import { EMOJIS } from "@src/constants";
import { fetchFact } from "@infrastructure/facts";
interface Props {
urgentItems: Item[];
unassignedItems: Item[];
}
export const simpleTaskReportMessage = async ({
urgentItems,
unassignedItems,
}: Props): Promise<DiscordItemMessage> => {
const factResult = await fetchFact();
const randomFact = factResult.ok ? factResult.val : "*Error fetching fact*";
const randomEmoji = EMOJIS[Math.floor(Math.random() * EMOJIS.length)];
const hasUrgent = urgentItems.length > 0;
const hasUnassigned = unassignedItems.length > 0;
const baseMessage =
!hasUrgent && !hasUnassigned
? "Nothing urgent or unassigned today! 🐀🥂"
: "Check out all upcoming tasks [here.](https://github.com/orgs/CarletonComputerScienceSociety/projects/18) 👀";
const urgentItemsLinkThreshold = 5;
const urgentItemsLinkBool = urgentItems.length <= urgentItemsLinkThreshold;
return {
title: `Daily Task Reminder ${randomEmoji}`,
message: `${baseMessage}\n\n💡 **Fun Fact**: ${randomFact}.`,
sections: [
...(hasUrgent
? [
{
title: "🔥 Urgent & Overdue",
items: urgentItems,
includeLinks: urgentItemsLinkBool,
},
]
: []),
...(hasUnassigned
? [
{
title: "📥 Unassigned Items",
items: unassignedItems,
includeLinks: false,
},
]
: []),
],
};
};