1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 05:02:37 +01:00

(api): add patch to emoji route

This commit is contained in:
Lobo Metalúrgico 2021-10-09 10:52:43 -03:00
parent 7cfca122ae
commit ec8b59c5e5

View File

@ -18,6 +18,11 @@ export interface EmojiCreateSchema {
roles?: string[]; roles?: string[];
} }
export interface EmojiModifySchema {
name?: string;
roles?: string[];
}
router.get("/", route({}), async (req: Request, res: Response) => { router.get("/", route({}), async (req: Request, res: Response) => {
const guild_id = req.params.guild_id; 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) => { router.delete("/:emoji_id", route({ permission: "MANAGE_EMOJIS_AND_STICKERS" }), async (req: Request, res: Response) => {
const guild_id = req.params.guild_id; const guild_id = req.params.guild_id;
const { emoji_id } = req.params; const { emoji_id } = req.params;