diff options
-rw-r--r-- | api/src/routes/users/@me/index.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts index dc0d1cb1..36b62b55 100644 --- a/api/src/routes/users/@me/index.ts +++ b/api/src/routes/users/@me/index.ts @@ -77,6 +77,14 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res: } } + if (body.discriminator) { + if (await User.findOne({ where: { discriminator: body.discriminator, username: body.username || user.username } })) { + throw FieldErrors({ + discriminator: { code: "INVALID_DISCRIMINATOR", message: "This discriminator is already in use." } + }); + } + } + user.assign(body); await user.save(); |