summary refs log tree commit diff
path: root/api/src/routes/guilds
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/routes/guilds')
-rw-r--r--api/src/routes/guilds/#guild_id/index.ts16
-rw-r--r--api/src/routes/guilds/index.ts2
2 files changed, 15 insertions, 3 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,