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;
|