blob: 052a638fded8dec55785afa53275fd98815250fb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import { GuildModel } from "@fosscord/server-util";
import { Router, Request, Response } from "express";
import { HTTPError } from "lambert-server";
const router = Router();
router.get("/", 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) throw new HTTPError("This guild has no vanity url", 204);
return res.json({ vanity_ur: guild.vanity_url });
});
export default router;
|