1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-06 19:02:33 +01:00

Update index.ts

This commit is contained in:
Samuel 2021-11-21 21:03:13 +01:00 committed by GitHub
parent 5d2f92427d
commit 49aae7b16f

View File

@ -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,6 +11,7 @@ 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;
@ -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);