posts "question of the day" to a discord webhook

Fetch sheet data on every Cron job

+3 -3
+3 -3
main.ts
··· 8 8 throw new Error("SHEET_ENDPOINT environment variable is not set"); 9 9 } 10 10 11 - const response = await fetch(endpoint); 12 - const { data } = await response.json(); 13 - 14 11 // @ts-ignore Deno.cron is unstable, run with --unstable-cron flag 15 12 Deno.cron("QOTD", Deno.env.get("CRON_STRING"), async () => { 16 13 // Open KV and get last index ··· 22 19 ); 23 20 const result = await kv.get<number>(["lastIndex"]); 24 21 let index = result.value ?? 0; 22 + 23 + const response = await fetch(endpoint); 24 + const { data } = await response.json(); 25 25 26 26 await sendDiscordNotification(data[index].question); 27 27 console.log(`Cron: posted question of index ${index} to Discord.`);