diff options
author | Intevel ツ <59223342+Intevel@users.noreply.github.com> | 2021-05-05 22:17:32 +0200 |
---|---|---|
committer | Intevel ツ <59223342+Intevel@users.noreply.github.com> | 2021-05-05 22:17:32 +0200 |
commit | 659b8070d096f7077b745822e1194ed939c222ee (patch) | |
tree | a20224992628a431aa6731a6efc2336b7e27a8bd /src | |
parent | [Route] PUT /guilds/:id/templates (diff) | |
download | server-659b8070d096f7077b745822e1194ed939c222ee.tar.xz |
[Route] GET /guilds/template/:code
Diffstat (limited to 'src')
-rw-r--r-- | src/routes/guilds/#guild_id/templates.ts | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/routes/guilds/#guild_id/templates.ts b/src/routes/guilds/#guild_id/templates.ts index 9cb972be..28947779 100644 --- a/src/routes/guilds/#guild_id/templates.ts +++ b/src/routes/guilds/#guild_id/templates.ts @@ -75,6 +75,21 @@ router.delete("/:template_id", async (req: Request, res: Response) => { res.send("Deleted"); }); +router.get("/:template_id", async (req: Request, res: Response) => { + + const guild_id = req.params.guild_id; + const { template_id } = req.params; + + const guild = await GuildModel.findOne({ id: guild_id }, { id: true }).exec(); + if (!guild) throw new HTTPError("Guild not found", 404); + if (!template_id) throw new HTTPError("Unknown template_id", 404); + + const template = await TemplateModel.findById({ _id: template_id }).exec(); + if (!template) throw new HTTPError("template not found", 404); + + res.json(toObject(template)).send(); +}); + router.put("/:template_id", async (req: Request, res: Response) => { const guild_id = req.params.guild_id; @@ -90,10 +105,10 @@ router.put("/:template_id", async (req: Request, res: Response) => { const template = await TemplateModel.findById({ _id: template_id }).exec(); if (!template) throw new HTTPError("template not found", 404); - /*const perms = await getPermission(req.user_id, guild_id); + const perms = await getPermission(req.user_id, guild_id); if (!perms.has("MANAGE_GUILD")) - throw new HTTPError("You missing the MANAGE_GUILD permission", 401);*/ + throw new HTTPError("You missing the MANAGE_GUILD permission", 401); var templateobj = await TemplateModel.findByIdAndUpdate({ _id: template_id, |