Discord Permissions will be revoked, when under a penalty
This commit is contained in:
@@ -10,18 +10,22 @@ export const eventCompleted = (event: Event, participant?: Participant) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
router.post("/set-standard-name", async (req, res) => {
|
||||
const { memberId, userId } = req.body;
|
||||
|
||||
export const setUserStandardNamePermissions = async ({
|
||||
memberId,
|
||||
userId,
|
||||
}: {
|
||||
memberId: string;
|
||||
userId: string;
|
||||
}) => {
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
id: userId,
|
||||
},
|
||||
});
|
||||
if (!user) {
|
||||
res.status(404).json({ error: "User not found" });
|
||||
return;
|
||||
}
|
||||
|
||||
const participant = await prisma.participant.findMany({
|
||||
where: {
|
||||
userId: user.id,
|
||||
@@ -72,6 +76,13 @@ router.post("/set-standard-name", async (req, res) => {
|
||||
await changeMemberRoles(memberId, [DISCORD_ROLES.PILOT], isPilot ? "add" : "remove");
|
||||
await changeMemberRoles(memberId, [DISCORD_ROLES.DISPATCHER], isDispatcher ? "add" : "remove");
|
||||
}
|
||||
};
|
||||
|
||||
router.post("/set-standard-name", async (req, res) => {
|
||||
const { memberId, userId } = req.body;
|
||||
|
||||
await setUserStandardNamePermissions({ memberId, userId });
|
||||
res.status(200).json({ message: "Standard name and permissions set" });
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user