summary refs log tree commit diff
diff options
context:
space:
mode:
authorIntevel ツ <59223342+Intevel@users.noreply.github.com>2021-05-08 16:30:44 +0200
committerIntevel ツ <59223342+Intevel@users.noreply.github.com>2021-05-08 16:30:44 +0200
commitd44d97d4932fd7f83f554a8c5aca02925d842628 (patch)
treef5aa308504a130685ac0859269d6a0b4b6ee29b3
parentUpdate welcome_screen.ts (diff)
downloadserver-d44d97d4932fd7f83f554a8c5aca02925d842628.tar.xz
[Route] GET /guilds/:id/vanity-url
-rw-r--r--src/routes/guilds/#guild_id/index.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/routes/guilds/#guild_id/index.ts b/src/routes/guilds/#guild_id/index.ts

index 2a7d9b38..e99ecbb1 100644 --- a/src/routes/guilds/#guild_id/index.ts +++ b/src/routes/guilds/#guild_id/index.ts
@@ -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;