diff --git a/src/routes/guilds/#guild_id/welcome_screen.ts b/src/routes/guilds/#guild_id/welcome_screen.ts
index 8fc5ac39..656a0ee0 100644
--- a/src/routes/guilds/#guild_id/welcome_screen.ts
+++ b/src/routes/guilds/#guild_id/welcome_screen.ts
@@ -13,7 +13,6 @@ router.get("/", async (req: Request, res: Response) => {
const guild_id = req.params.guild_id;
const guild = await GuildModel.findOne({ id: guild_id });
- if (!guild) throw new HTTPError("Guild not found", 404);
await isMember(req.user_id, guild_id);
@@ -25,22 +24,21 @@ router.post("/", check(GuildAddChannelToWelcomeScreenSchema), async (req: Reques
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
- }
+ };
const perms = await getPermission(req.user_id, guild_id);
perms.hasThrow("MANAGE_GUILD");
- if(!guild.welcome_screen.enabled) throw new HTTPError("Welcome screen disabled", 400);
- if(guild.welcome_screen.welcome_channels.some(channel => channel.channel_id === body.channel_id)) throw new Error("Welcome Channel exists")
-
+ if (!guild.welcome_screen.enabled) throw new HTTPError("Welcome screen disabled", 400);
+ if (guild.welcome_screen.welcome_channels.some((channel) => channel.channel_id === body.channel_id))
+ throw new Error("Welcome Channel exists");
await GuildModel.findOneAndUpdate(
{
- id: guild_id,
+ id: guild_id
},
{ $push: { "welcome_screen.welcome_channels": channelObject } }
).exec();
@@ -48,5 +46,4 @@ router.post("/", check(GuildAddChannelToWelcomeScreenSchema), async (req: Reques
res.sendStatus(204);
});
-
export default router;
|