diff options
author | Lobo Metalúrgico <43734867+LoboMetalurgico@users.noreply.github.com> | 2021-10-09 10:52:43 -0300 |
---|---|---|
committer | Lobo Metalúrgico <43734867+LoboMetalurgico@users.noreply.github.com> | 2021-10-09 10:52:43 -0300 |
commit | ec8b59c5e5aa20c4865c5cab0864178a185deb1e (patch) | |
tree | b8764fee96178d9cc3138acefbe6f0c72a7ae0f2 /api/src/routes/guilds/#guild_id/emoji.ts | |
parent | Merge remote-tracking branch 'upstream/master' into milestoneV1/routes/implem... (diff) | |
download | server-ec8b59c5e5aa20c4865c5cab0864178a185deb1e.tar.xz |
(api): add patch to emoji route
Diffstat (limited to '')
-rw-r--r-- | api/src/routes/guilds/#guild_id/emoji.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/api/src/routes/guilds/#guild_id/emoji.ts b/api/src/routes/guilds/#guild_id/emoji.ts index f1e427e8..f14790ed 100644 --- a/api/src/routes/guilds/#guild_id/emoji.ts +++ b/api/src/routes/guilds/#guild_id/emoji.ts @@ -18,6 +18,11 @@ export interface EmojiCreateSchema { roles?: string[]; } +export interface EmojiModifySchema { + name?: string; + roles?: string[]; +} + router.get("/", route({}), async (req: Request, res: Response) => { const guild_id = req.params.guild_id; @@ -53,6 +58,27 @@ router.post("/", route({ body: "EmojiCreateSchema", permission: "MANAGE_EMOJIS_A }); */ +router.patch("/:emoji_id", route({ body: "EmojiModifySchema", permission: "MANAGE_EMOJIS_AND_STICKERS" }), async (req: Request, res: Response) => { + const { emoji_id, guild_id } = req.params; + const body = req.body as EmojiModifySchema; + + const emoji = new Emoji({ ...body, id: emoji_id, guild_id: guild_id }); + + await Promise.all([ + emoji.save(), + emitEvent({ + event: "GUILD_EMOJI_UPDATE", + guild_id: guild_id, + data: { + guild_id: guild_id, + emojis: await Emoji.find({ guild_id: guild_id }) + } + } as GuildEmojiUpdateEvent) + ]) + + return res.json(emoji); +}); + router.delete("/:emoji_id", route({ permission: "MANAGE_EMOJIS_AND_STICKERS" }), async (req: Request, res: Response) => { const guild_id = req.params.guild_id; const { emoji_id } = req.params; |