added chrom

This commit is contained in:
PxlLoewe
2025-06-05 10:18:52 -07:00
parent 59f3da5c84
commit 63166b602a
9 changed files with 65 additions and 43 deletions

View File

@@ -1,10 +1,11 @@
import { getMoodleCourseCompletionStatus, getMoodleUserById } from "./moodle";
import { CronJob } from "cron";
import { DISCORD_ROLES, prisma } from "@repo/db";
import { DISCORD_ROLES, ParticipantLog, prisma } from "@repo/db";
import { sendCourseCompletedEmail } from "modules/mail";
import { handleParticipantFinished } from "modules/event";
import { eventCompleted } from "helper/events";
import { addRolesToMember, removeRolesFromMember } from "modules/discord";
import { JsonValueType } from "@repo/db/zod";
const syncMoodleIds = async () => {
try {
@@ -122,9 +123,23 @@ const checkUnfinishedParticipants = async () => {
if (completed) return;
if (!p.Event.discordRoleId) {
await prisma.participant.update({
where: {
id: p.id,
},
data: {
inscriptionWorkflowCompleted: true,
},
});
return;
}
console.log(
`User ${p.User.firstname} ${p.User.lastname} - ${p.User.publicId} did not finish event ${p.Event.name}`,
);
if (p.User.discordAccounts[0] && p.Event.discordRoleId) {
await addRolesToMember(p.User.discordAccounts[0].discordId, [p.Event.discordRoleId]);
prisma.participant.update({
await prisma.participant.update({
where: {
id: p.id,
},
@@ -135,7 +150,7 @@ const checkUnfinishedParticipants = async () => {
event: "Discord-Rolle hinzugefügt",
timestamp: new Date(),
user: "system",
},
} as ParticipantLog as any,
},
},
});