diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-03 15:27:00 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-03 15:27:00 +0200 |
commit | c944babc9695cd012b4a032b7dd4224ec19003f2 (patch) | |
tree | bb8bdc42f5720045017846c7a41ac9ec0b6dae70 /api/src/routes/guilds/#guild_id/index.ts | |
parent | :bug: fix member roles + list (diff) | |
download | server-c944babc9695cd012b4a032b7dd4224ec19003f2.tar.xz |
:bug: fix #311
Diffstat (limited to 'api/src/routes/guilds/#guild_id/index.ts')
-rw-r--r-- | api/src/routes/guilds/#guild_id/index.ts | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/api/src/routes/guilds/#guild_id/index.ts b/api/src/routes/guilds/#guild_id/index.ts index 567898dd..9d302a48 100644 --- a/api/src/routes/guilds/#guild_id/index.ts +++ b/api/src/routes/guilds/#guild_id/index.ts @@ -37,12 +37,22 @@ router.patch("/", check(GuildUpdateSchema), async (req: Request, res: Response) if (body.banner) body.banner = await handleFile(`/banners/${guild_id}`, body.banner); if (body.splash) body.splash = await handleFile(`/splashes/${guild_id}`, body.splash); - const guild = await Guild.findOneOrFail({ id: guild_id }); + var guild = await Guild.findOneOrFail({ + where: { id: guild_id }, + relations: ["emojis", "roles", "stickers"] + }); + // TODO: check if body ids are valid guild.assign(body); - await Promise.all([guild.save(), emitEvent({ event: "GUILD_UPDATE", data: guild, guild_id } as GuildUpdateEvent)]); + const data = guild.toJSON(); + // TODO: guild hashes + // TODO: fix vanity_url_code, template_id + delete data.vanity_url_code; + delete data.template_id; - return res.json(guild); + await Promise.all([guild.save(), emitEvent({ event: "GUILD_UPDATE", data, guild_id } as GuildUpdateEvent)]); + + return res.json(data); }); export default router; |