Ping roles on inactivity webhook message

This commit is contained in:
Regalijan 2024-02-21 23:02:04 -05:00
parent 0f257ce42f
commit 89ff059176
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -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",