summary refs log tree commit diff
path: root/src/api/routes/guilds
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-28 17:07:36 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-28 17:07:36 +1000
commit02913b5e24e6e7c5fa643330534214b0ac90e550 (patch)
treeea4fad54f6b3682a9ff8f817fe66ad1cf4d8d3e2 /src/api/routes/guilds
parentFix user guild settings (diff)
downloadserver-02913b5e24e6e7c5fa643330534214b0ac90e550.tar.xz
Discovery splashes + fix guild icons disappearing on settings change
Diffstat (limited to 'src/api/routes/guilds')
-rw-r--r--src/api/routes/guilds/#guild_id/index.ts23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/api/routes/guilds/#guild_id/index.ts b/src/api/routes/guilds/#guild_id/index.ts
index 04cb76c2..a20660da 100644
--- a/src/api/routes/guilds/#guild_id/index.ts
+++ b/src/api/routes/guilds/#guild_id/index.ts
@@ -49,22 +49,31 @@ router.patch(
 				"MANAGE_GUILD",
 			);
 
+		var guild = await Guild.findOneOrFail({
+			where: { id: guild_id },
+			relations: ["emojis", "roles", "stickers"],
+		});
+
 		// TODO: guild update check image
 
-		if (body.icon)
+		if (body.icon && body.icon != guild.icon)
 			body.icon = await handleFile(`/icons/${guild_id}`, body.icon);
-		if (body.banner)
+
+		if (body.banner && body.banner !== guild.banner)
 			body.banner = await handleFile(`/banners/${guild_id}`, body.banner);
-		if (body.splash)
+
+		if (body.splash && body.splash !== guild.splash)
 			body.splash = await handleFile(
 				`/splashes/${guild_id}`,
 				body.splash,
 			);
 
-		var guild = await Guild.findOneOrFail({
-			where: { id: guild_id },
-			relations: ["emojis", "roles", "stickers"],
-		});
+		if (body.discovery_splash && body.discovery_splash !== guild.discovery_splash)
+			body.splash = await handleFile(
+				`/discovery-splashes/${guild_id}`,
+				body.discovery_splash,
+			);
+
 		// TODO: check if body ids are valid
 		guild.assign(body);