[Route] GET /guilds/template/:code
This commit is contained in:
parent
ad793af2d7
commit
659b8070d0
@ -75,6 +75,21 @@ router.delete("/:template_id", async (req: Request, res: Response) => {
|
|||||||
res.send("Deleted");
|
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) => {
|
router.put("/:template_id", async (req: Request, res: Response) => {
|
||||||
|
|
||||||
const guild_id = req.params.guild_id;
|
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();
|
const template = await TemplateModel.findById({ _id: template_id }).exec();
|
||||||
if (!template) throw new HTTPError("template not found", 404);
|
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"))
|
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({
|
var templateobj = await TemplateModel.findByIdAndUpdate({
|
||||||
_id: template_id,
|
_id: template_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user