summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-12-24 16:28:00 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-12-24 16:28:00 +1100
commit35938556fe1ed6cbbde636c9d88beeeb85105e9d (patch)
tree8021e869d7e86c05b3c9de5aea38bd118dd13fe8 /src/util
parentMerge branch 'maddy/refactor' of github.com:fosscord/fosscord-server into mad... (diff)
downloadserver-35938556fe1ed6cbbde636c9d88beeeb85105e9d.tar.xz
Fix creating bot accounts
Diffstat (limited to 'src/util')
-rw-r--r--src/util/entities/User.ts16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts
index 79ea6c3c..eeffab5b 100644
--- a/src/util/entities/User.ts
+++ b/src/util/entities/User.ts
@@ -306,12 +306,14 @@ export class User extends BaseClass {
 		username,
 		password,
 		date_of_birth,
+		id,
 		req,
 	}: {
 		username: string;
 		password?: string;
 		email?: string;
 		date_of_birth?: Date; // "2000-04-03"
+		id?: string,
 		req?: any;
 	}) {
 		// trim special uf8 control characters -> Backspace, Newline, ...
@@ -334,10 +336,14 @@ export class User extends BaseClass {
 		const language =
 			req.language === "en" ? "en-US" : req.language || "en-US";
 
+		const settings = UserSettings.create({
+			locale: language,
+		})
+
 		const user = User.create({
 			username: username,
 			discriminator,
-			id: Snowflake.generate(),
+			id: id || Snowflake.generate(),
 			email: email,
 			rights: Config.get().register.defaultRights,
 			data: {
@@ -348,12 +354,14 @@ export class User extends BaseClass {
 			premium_type: Config.get().defaults.user.premium_type,
 			premium: Config.get().defaults.user.premium,
 			verified: Config.get().defaults.user.verified,
-			settings: { ...new UserSettings(), locale: language }
+			settings: settings,
 		});
 
 		user.validate();
-		await user.save();
-		await user.settings.save();
+		await Promise.all([
+			user.save(),
+			settings.save(),
+		])
 
 		setImmediate(async () => {
 			if (Config.get().guild.autoJoin.enabled) {