summary refs log tree commit diff
path: root/util/src/entities/User.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-10 11:03:32 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-10 11:03:32 +0200
commit74bd98737acf89d9d56ee66a68694d82f591d591 (patch)
treeb93c79b510a962316fb14a125cac6e177e600c53 /util/src/entities/User.ts
parent:art: clean up dependencies (diff)
downloadserver-74bd98737acf89d9d56ee66a68694d82f591d591.tar.xz
:art: clean up imports + classes
Diffstat (limited to '')
-rw-r--r--util/src/entities/User.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts

index 97564af3..662ab031 100644 --- a/util/src/entities/User.ts +++ b/util/src/entities/User.ts
@@ -198,7 +198,7 @@ export class User extends BaseClass { // randomly generates a discriminator between 1 and 9999 and checks max five times if it already exists // if it all five times already exists, abort with USERNAME_TOO_MANY_USERS error // else just continue - // TODO: is there any better way to generate a random discriminator only once, without checking if it already exists in the mongodb database? + // TODO: is there any better way to generate a random discriminator only once, without checking if it already exists in the database? for (let tries = 0; tries < 5; tries++) { discriminator = Math.randomIntBetween(1, 9999).toString().padStart(4, "0"); exists = await User.findOne({ where: { discriminator, username: username }, select: ["id"] }); @@ -219,7 +219,7 @@ export class User extends BaseClass { // if nsfw_allowed is null/undefined it'll require date_of_birth to set it to true/false const language = req.language === "en" ? "en-US" : req.language || "en-US"; - const user = await new User({ + const user = new User({ created_at: new Date(), username: username, discriminator, @@ -246,7 +246,10 @@ export class User extends BaseClass { }, settings: { ...defaultSettings, locale: language }, fingerprints: [], - }).save(); + }); + + console.log(user); + await user.save(); if (Config.get().guild.autoJoin.enabled) { for (const guild of Config.get().guild.autoJoin.guilds || []) {