summary refs log tree commit diff
path: root/src/routes
diff options
context:
space:
mode:
authorIntevel ツ <59223342+Intevel@users.noreply.github.com>2021-05-08 14:57:30 +0200
committerIntevel ツ <59223342+Intevel@users.noreply.github.com>2021-05-08 14:57:30 +0200
commit462c40521a85f2ecf19cccb46a6910fab669b1c7 (patch)
tree387a781a1b4bbf78c5c916ab0267f01900fa84fd /src/routes
parentCreate welcome_screen.ts (diff)
downloadserver-462c40521a85f2ecf19cccb46a6910fab669b1c7.tar.xz
Update welcome_screen.ts
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/guilds/#guild_id/welcome_screen.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/routes/guilds/#guild_id/welcome_screen.ts b/src/routes/guilds/#guild_id/welcome_screen.ts
index 98f80509..86eb9996 100644
--- a/src/routes/guilds/#guild_id/welcome_screen.ts
+++ b/src/routes/guilds/#guild_id/welcome_screen.ts
@@ -17,5 +17,29 @@ router.get("/", async (req: Request, res: Response) => {
 	res.json(toObject(guild.welcome_screen));
 });
 
+router.post("/", check(GuildAddChannelToWelcomeScreenSchema), async (req: Request, res: Response) => {
+	const guild_id = req.params.id;
+	const body = req.body as GuildAddChannelToWelcomeScreenSchema;
+
+	const guild = await GuildModel.findOne({ id: guild_id }).exec();
+	if (!guild) throw new HTTPError("Guild not found", 404);
+
+	var channelObject = {
+		...body
+	}
+
+	if(guild.welcome_screen.welcome_channels.some(channel => channel.channel_id === body.channel_id)){
+
+
+	await GuildModel.findOneAndUpdate(
+		{
+			id: guild_id,
+		},
+		{ $push: { "welcome_screen.welcome_channels": channelObject } }
+	).exec();
+
+	res.json(toObject(guild.welcome_screen));
+});
+
 
 export default router;