diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-24 16:35:04 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-24 16:35:04 +0200 |
commit | ef4d4a318176c3e572adc17427a8b8c728a618ab (patch) | |
tree | d95fedbf18b7b7438613b08b72eb30fa5fca8921 /api/src/routes/guilds/#guild_id/welcome_screen.ts | |
parent | :sparkles: typeorm entities (diff) | |
download | server-ef4d4a318176c3e572adc17427a8b8c728a618ab.tar.xz |
:construction: api
Diffstat (limited to 'api/src/routes/guilds/#guild_id/welcome_screen.ts')
-rw-r--r-- | api/src/routes/guilds/#guild_id/welcome_screen.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/api/src/routes/guilds/#guild_id/welcome_screen.ts b/api/src/routes/guilds/#guild_id/welcome_screen.ts index c717042e..b457efb6 100644 --- a/api/src/routes/guilds/#guild_id/welcome_screen.ts +++ b/api/src/routes/guilds/#guild_id/welcome_screen.ts @@ -1,5 +1,5 @@ import { Request, Response, Router } from "express"; -import { GuildModel, getPermission, toObject, Snowflake } from "@fosscord/util"; +import { Guild, getPermission, toObject, Snowflake } from "@fosscord/util"; import { HTTPError } from "lambert-server"; import { check } from "../../../util/instanceOf"; @@ -12,18 +12,18 @@ const router: Router = Router(); router.get("/", async (req: Request, res: Response) => { const guild_id = req.params.guild_id; - const guild = await GuildModel.findOne({ id: guild_id }); + const guild = await Guild.findOneOrFail({ id: guild_id }); await isMember(req.user_id, guild_id); - res.json(toObject(guild.welcome_screen)); + res.json(guild.welcome_screen); }); router.post("/", check(GuildAddChannelToWelcomeScreenSchema), async (req: Request, res: Response) => { const guild_id = req.params.guild_id; const body = req.body as GuildAddChannelToWelcomeScreenSchema; - const guild = await GuildModel.findOne({ id: guild_id }).exec(); + const guild = await Guild.findOneOrFail({ id: guild_id }); var channelObject = { ...body @@ -36,12 +36,12 @@ router.post("/", check(GuildAddChannelToWelcomeScreenSchema), async (req: Reques if (guild.welcome_screen.welcome_channels.some((channel) => channel.channel_id === body.channel_id)) throw new Error("Welcome Channel exists"); - await GuildModel.findOneAndUpdate( + await Guild.findOneOrFailAndUpdate( { id: guild_id }, { $push: { "welcome_screen.welcome_channels": channelObject } } - ).exec(); + ); res.sendStatus(204); }); |