now no two users can have the same uuid

This commit is contained in:
oat 2020-10-12 21:13:45 +03:00
parent 0a150ad343
commit 4cbe252852
Signed by: oat
GPG key ID: DD83A9617A252385

View file

@ -37,6 +37,12 @@ export function run(app) {
let userUuid = '';
if (users.length === 0) {
let newUuid = uuid.v4();
while (User.find({uuid: newUuid})[0]) {
newUuid = uuid.v4();
}
const newUser = new User({
id: String(userInfo.data.id),
createdAt: new Date(),
@ -45,7 +51,7 @@ export function run(app) {
discriminator: userInfo.data.discriminator,
avatar: userInfo.data.avatar,
uuid: uuid.v4(),
uuid: newUuid,
});
userUuid = newUser.get('uuid');