From 89ff059176b499da0ee6f366a2c3eb2af3387c21 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Wed, 21 Feb 2024 23:02:04 -0500 Subject: [PATCH] Ping roles on inactivity webhook message --- functions/api/inactivity/new.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/functions/api/inactivity/new.ts b/functions/api/inactivity/new.ts index 3ab1f3d..675dcb1 100644 --- a/functions/api/inactivity/new.ts +++ b/functions/api/inactivity/new.ts @@ -49,16 +49,20 @@ export async function onRequestPost(context: RequestContext) { .run(); const departmentsToNotify = []; + const departmentRoles = []; const { env } = context; - for (const department of departments) + for (const department of departments) { departmentsToNotify.push(env[`${department}_INACTIVITY_WEBHOOK`]); + departmentRoles.push(env[`${department}_INACTIVITY_ROLE`]); + } const webhookPromises = []; - for (const departmentWebhook of departmentsToNotify) + for (let i = 0; i < departmentsToNotify.length; i++) webhookPromises.push( - fetch(departmentWebhook, { + fetch(departmentsToNotify[i], { body: JSON.stringify({ + content: `<@&${departmentRoles[i]}>`, embeds: [ { title: "Inactivity Notice Submitted",