posts "question of the day" to a discord webhook

Embed customization

+15 -5
+15 -5
utils/discordUtils.ts
··· 3 3 await load({ export: true }); 4 4 5 5 export async function sendDiscordNotification(quote: string) { 6 - const embed = { 7 - title: "❓❔ Question of the Day ❓❔", 6 + const embed1 = { 7 + color: 0xFEF250, // lemon yellow 8 + image: { url: Deno.env.get("IMAGE_URL") }, 9 + }; 10 + 11 + const embed2 = { 12 + title: `· · ─ ·𝒒𝒖𝒆𝒔𝒕𝒊𝒐𝒏 𝒐𝒇 𝒕𝒉𝒆 𝒅𝒂𝒚 · ─ · ·`, 8 13 color: 0xFEF250, // lemon yellow 9 14 description: quote, 10 - //timestamp: new Date().toISOString(), 15 + thumbnail: { url: Deno.env.get("THUMBNAIL_URL") }, 16 + footer: { text: `𐔌՞. .՞𐦯` }, 11 17 }; 12 18 13 - await fetch(Deno.env.get("DISCORD_WEBHOOK_URL")!, { 19 + const response = await fetch(Deno.env.get("DISCORD_WEBHOOK_URL")!, { 14 20 method: "POST", 15 21 headers: { 16 22 "Content-Type": "application/json", 17 23 }, 18 24 body: JSON.stringify({ 19 - embeds: [embed], 25 + embeds: [embed1, embed2], 20 26 }), 21 27 }); 28 + 29 + if (!response.ok) { 30 + throw new Error(`Discord webhook failed: ${response.status}`); 31 + } 22 32 }