diff options
author | Samuel <34555296+Flam3rboy@users.noreply.github.com> | 2021-11-21 21:03:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-21 21:03:13 +0100 |
commit | b47a812ac7a9b3b6e88520333f1184a32122cd8b (patch) | |
tree | db79c7d953296bcba56a5ada737cf955dbd52cf8 | |
parent | Update util/src/entities/Config.ts (diff) | |
download | server-b47a812ac7a9b3b6e88520333f1184a32122cd8b.tar.xz |
Update index.ts
-rw-r--r-- | api/src/routes/guilds/templates/index.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/api/src/routes/guilds/templates/index.ts b/api/src/routes/guilds/templates/index.ts index 98e42d1c..3d922e85 100644 --- a/api/src/routes/guilds/templates/index.ts +++ b/api/src/routes/guilds/templates/index.ts @@ -4,7 +4,6 @@ import { route } from "@fosscord/api"; import { DiscordApiErrors } from "@fosscord/util"; import fetch from "node-fetch"; const router: Router = Router(); -const { enabled, allowTemplateCreation, allowDiscordTemplates, allowRaws } = Config.get().templates; export interface GuildTemplateCreateSchema { name: string; @@ -12,10 +11,11 @@ export interface GuildTemplateCreateSchema { } router.get("/:code", route({}), async (req: Request, res: Response) => { + const { allowDiscordTemplates, allowRaws, enabled } = Config.get().templates; if (!enabled) res.json({ code: 403, message: "Template creation & usage is disabled on this instance." }).sendStatus(403); const { code } = req.params; - + if (code.startsWith("discord:")) { if (!allowDiscordTemplates) return res.json({ code: 403, message: "Discord templates cannot be used on this instance." }).sendStatus(403); const discordTemplateID = code.split("discord:", 2)[1]; @@ -38,6 +38,7 @@ router.get("/:code", route({}), async (req: Request, res: Response) => { }); router.post("/:code", route({ body: "GuildTemplateCreateSchema" }), async (req: Request, res: Response) => { + const { enabled, allowTemplateCreation, allowDiscordTemplates, allowRaws } = Config.get().templates; if (!enabled) return res.json({ code: 403, message: "Template creation & usage is disabled on this instance." }).sendStatus(403); if (!allowTemplateCreation) return res.json({ code: 403, message: "Template creation is disabled on this instance." }).sendStatus(403); |