summary refs log tree commit diff
path: root/api/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-30 12:15:06 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-30 12:15:06 +0200
commit4abc758991d3f92a6404f269770fb92f5375d1e4 (patch)
tree925932613c1632e82d74202ef32277ae3e8e94c5 /api/src
parent:zap: only local rate limit to prevent to much pressure on the database (diff)
downloadserver-4abc758991d3f92a6404f269770fb92f5375d1e4.tar.xz
:construction: typeorm
Diffstat (limited to 'api/src')
-rw-r--r--api/src/routes/guilds/#guild_id/roles.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/templates.ts2
-rw-r--r--api/src/routes/guilds/index.ts88
3 files changed, 42 insertions, 50 deletions
diff --git a/api/src/routes/guilds/#guild_id/roles.ts b/api/src/routes/guilds/#guild_id/roles.ts
index e9e777b9..796a8eb8 100644
--- a/api/src/routes/guilds/#guild_id/roles.ts
+++ b/api/src/routes/guilds/#guild_id/roles.ts
@@ -40,7 +40,7 @@ router.post("/", check(RoleModifySchema), async (req: Request, res: Response) =>
 		managed: false,
 		position: 0,
 		tags: null,
-		permissions: perms.bitfield & (body.permissions || 0n)
+		permissions: String(perms.bitfield & (body.permissions || 0n))
 	}).save();
 
 	await emitEvent({
diff --git a/api/src/routes/guilds/#guild_id/templates.ts b/api/src/routes/guilds/#guild_id/templates.ts
index e1d2f5fd..a7613abf 100644
--- a/api/src/routes/guilds/#guild_id/templates.ts
+++ b/api/src/routes/guilds/#guild_id/templates.ts
@@ -17,7 +17,7 @@ const TemplateGuildProjection: (keyof Guild)[] = [
 	"preferred_locale",
 	"afk_timeout",
 	"roles",
-	"channels",
+	// "channels",
 	"afk_channel_id",
 	"system_channel_id",
 	"system_channel_flags",
diff --git a/api/src/routes/guilds/index.ts b/api/src/routes/guilds/index.ts
index 1e83cf13..020aba6a 100644
--- a/api/src/routes/guilds/index.ts
+++ b/api/src/routes/guilds/index.ts
@@ -19,63 +19,55 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) =
 	}
 
 	const guild_id = Snowflake.generate();
-	const guild = new Guild({
-		name: body.name,
-		region: Config.get().regions.default,
-		owner_id: req.user_id,
-		icon: undefined,
-		afk_channel_id: undefined,
-		afk_timeout: 300,
-		application_id: undefined,
-		banner: undefined,
-		default_message_notifications: 0,
-		description: undefined,
-		splash: undefined,
-		discovery_splash: undefined,
-		explicit_content_filter: 0,
-		features: [],
-		id: guild_id,
-		large: undefined,
-		max_members: 250000,
-		max_presences: 250000,
-		max_video_channel_users: 25,
-		presence_count: 0,
-		member_count: 0, // will automatically be increased by addMember()
-		mfa_level: 0,
-		preferred_locale: "en-US",
-		premium_subscription_count: 0,
-		premium_tier: 0,
-		public_updates_channel_id: undefined,
-		rules_channel_id: undefined,
-		system_channel_flags: "0",
-		system_channel_id: undefined,
-		unavailable: false,
-		vanity_url_code: undefined,
-		verification_level: 0,
-		welcome_screen: {
-			enabled: false,
-			description: "No description",
-			welcome_channels: []
-		},
-		widget_channel_id: undefined,
-		widget_enabled: false
-	});
-
-	const [guild_doc, role] = await Promise.all([
-		new Guild(guild).save(),
-		new Role({
+	const guild = new Guild(
+		{
+			name: body.name,
+			region: Config.get().regions.default,
+			owner_id: req.user_id,
+			afk_timeout: 300,
+			default_message_notifications: 0,
+			explicit_content_filter: 0,
+			features: [],
 			id: guild_id,
+			max_members: 250000,
+			max_presences: 250000,
+			max_video_channel_users: 25,
+			presence_count: 0,
+			member_count: 0, // will automatically be increased by addMember()
+			mfa_level: 0,
+			preferred_locale: "en-US",
+			premium_subscription_count: 0,
+			premium_tier: 0,
+			system_channel_flags: "0",
+			unavailable: false,
+			verification_level: 0,
+			welcome_screen: {
+				enabled: false,
+				description: "No description",
+				welcome_channels: []
+			},
+			widget_enabled: false
+		},
+		{ id: guild_id }
+	);
+	const role = new Role(
+		{
 			guild_id: guild_id,
 			color: 0,
 			hoist: false,
 			managed: false,
 			mentionable: false,
 			name: "@everyone",
-			permissions: 2251804225n,
+			permissions: String("2251804225"),
 			position: 0,
 			tags: null
-		}).save()
-	]);
+		},
+		{
+			id: guild_id
+		}
+	);
+
+	await Promise.all([guild.save(), role.save()]);
 
 	if (!body.channels || !body.channels.length) body.channels = [{ id: "01", type: 0, name: "general" }];