fix user updating

This commit is contained in:
Hri7566 2021-05-09 21:13:15 -04:00
parent 234e034a8d
commit b45f1d0d59
1 changed files with 8 additions and 10 deletions

View File

@ -69,17 +69,15 @@ class Database {
} }
static async updateUser(_id, data) { static async updateUser(_id, data) {
UserModel.findOneAndUpdate({_id: _id}, data, {new: true}, (err, doc) => { let user = await UserModel.findOne({_id: _id}).exec();
if (err) { UserModel.updateOne({_id: _id}, {
logger.error(err); name: data.name,
return err; color: data.color,
} _id: data._id,
flags: data.flags
if (doc == null) {
logger.warn('Could not find user to save.');
return;
}
}); });
await user.save();
} }
static async wipe() { static async wipe() {