Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ping roles on inactivity webhook message
  • Loading branch information
regalijan committed Feb 22, 2024
1 parent 0f257ce commit 89ff059
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions functions/api/inactivity/new.ts
Expand Up @@ -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",
Expand Down

0 comments on commit 89ff059

Please sign in to comment.