[Route] GET /guilds/:id/vanity-url

This commit is contained in:
Intevel ツ 2021-05-08 16:30:44 +02:00
parent e5f731ba97
commit d44d97d493

View File

@ -82,4 +82,15 @@ router.post("/delete", async (req: Request, res: Response) => {
return res.sendStatus(204);
});
router.get("/vanity-url", async (req: Request, res: Response) => {
const { guild_id } = req.params;
const guild = await GuildModel.findOne({ id: guild_id }).exec();
if (!guild) throw new HTTPError("Guild does not exist", 404);
if(!guild.vanity_url_code) throw new HTTPError("This guild has no vanity url", 204)
return res.json(guild.vanity_url_code);
});
export default router;