summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/routes/guilds/#guild_id/index.ts16
-rw-r--r--api/src/routes/guilds/index.ts2
-rw-r--r--api/src/schema/Guild.ts2
3 files changed, 16 insertions, 4 deletions
diff --git a/api/src/routes/guilds/#guild_id/index.ts b/api/src/routes/guilds/#guild_id/index.ts
index 567898dd..9d302a48 100644
--- a/api/src/routes/guilds/#guild_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/index.ts
@@ -37,12 +37,22 @@ router.patch("/", check(GuildUpdateSchema), async (req: Request, res: Response)
 	if (body.banner) body.banner = await handleFile(`/banners/${guild_id}`, body.banner);
 	if (body.splash) body.splash = await handleFile(`/splashes/${guild_id}`, body.splash);
 
-	const guild = await Guild.findOneOrFail({ id: guild_id });
+	var guild = await Guild.findOneOrFail({
+		where: { id: guild_id },
+		relations: ["emojis", "roles", "stickers"]
+	});
+	// TODO: check if body ids are valid
 	guild.assign(body);
 
-	await Promise.all([guild.save(), emitEvent({ event: "GUILD_UPDATE", data: guild, guild_id } as GuildUpdateEvent)]);
+	const data = guild.toJSON();
+	// TODO: guild hashes
+	// TODO: fix vanity_url_code, template_id
+	delete data.vanity_url_code;
+	delete data.template_id;
 
-	return res.json(guild);
+	await Promise.all([guild.save(), emitEvent({ event: "GUILD_UPDATE", data, guild_id } as GuildUpdateEvent)]);
+
+	return res.json(data);
 });
 
 export default router;
diff --git a/api/src/routes/guilds/index.ts b/api/src/routes/guilds/index.ts
index b4f6b3d2..7c0b7abc 100644
--- a/api/src/routes/guilds/index.ts
+++ b/api/src/routes/guilds/index.ts
@@ -40,6 +40,8 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) =
 		premium_tier: 0,
 		system_channel_flags: 0,
 		unavailable: false,
+		nsfw: false,
+		nsfw_level: 0,
 		verification_level: 0,
 		welcome_screen: {
 			enabled: false,
diff --git a/api/src/schema/Guild.ts b/api/src/schema/Guild.ts
index 0f9fd884..7c96905e 100644
--- a/api/src/schema/Guild.ts
+++ b/api/src/schema/Guild.ts
@@ -33,7 +33,7 @@ export const GuildUpdateSchema = {
 	$icon: String,
 	$verification_level: Number,
 	$default_message_notifications: Number,
-	$system_channel_flags: String,
+	$system_channel_flags: Number,
 	$system_channel_id: String,
 	$explicit_content_filter: Number,
 	$public_updates_channel_id: String,