diff --git a/apps/dispatch-server/routes/dispatcher.ts b/apps/dispatch-server/routes/dispatcher.ts index 31dd6460..f021dce2 100644 --- a/apps/dispatch-server/routes/dispatcher.ts +++ b/apps/dispatch-server/routes/dispatcher.ts @@ -1,6 +1,7 @@ import { AdminMessage, getPublicUser, Prisma, prisma } from "@repo/db"; import { Router } from "express"; import { io } from "index"; +import { renameMember } from "modules/discord"; import { pubClient } from "modules/redis"; const router: Router = Router(); @@ -24,8 +25,21 @@ router.patch("/:id", async (req, res) => { data: { ...disaptcherUpdate, }, + include: { user: true }, }); + const discordAccount = await prisma.discordAccount.findFirst({ + where: { + userId: newDispatcher.userId, + }, + }); + if (discordAccount?.id) { + await renameMember( + discordAccount.discordId.toString(), + `${getPublicUser(newDispatcher.user).fullName} • ${newDispatcher.zone}`, + ); + } + res.json(newDispatcher); });