🐛 user settings

This commit is contained in:
Flam3rboy committed 2021-10-17 00:41:06 +02:00
1 parent 6f0cf477c5
commit 15fbb134cf
1 file changed
+3 -2
+3 -2
View File
@@ -10,8 +10,9 @@ router.patch("/", route({ body: "UserSettingsSchema" }), async (req: Request, re
const body = req.body as UserSettings;
if (body.locale === "en") body.locale = "en-US"; // fix discord client crash on unkown locale
// only users can update user settings
await User.update({ id: req.user_id, bot: false }, { settings: body });
const user = await User.findOneOrFail({ id: req.user_id, bot: false });
user.settings = { ...user.settings, ...body };
await user.save();
res.sendStatus(204);
});