2 files changed, 32 insertions, 0 deletions
diff --git a/src/routes/guilds/#guild_id/templates.ts b/src/routes/guilds/#guild_id/templates.ts
new file mode 100644
index 00000000..65d739c6
--- /dev/null
+++ b/src/routes/guilds/#guild_id/templates.ts
@@ -0,0 +1,22 @@
+import { Request, Response, Router } from "express";
+import { TemplateModel, GuildModel, getPermission, toObject } from "@fosscord/server-util";
+import { HTTPError } from "lambert-server";
+import { TemplateCreateSchema } from "../../../schema/Template";
+import { emitEvent } from "../../../util/Event";
+import { check } from "../../../util/instanceOf";
+import { getPublicUser } from "../../../util/User";
+
+const router: Router = Router();
+
+router.get("/", async (req: Request, res: Response) => {
+ const guild_id = req.params.id;
+
+ const guild = await GuildModel.exists({ id: guild_id });
+ if (!guild) throw new HTTPError("Guild not found", 404);
+
+ var templates = await TemplateModel.find({ source_guild_id: guild_id }).exec();
+ return res.json(toObject(templates));
+});
+
+
+export default router;
diff --git a/src/schema/Template.ts b/src/schema/Template.ts
new file mode 100644
index 00000000..6d47aa75
--- /dev/null
+++ b/src/schema/Template.ts
@@ -0,0 +1,10 @@
+export const TemplateCreateSchema = {
+ name: String,
+ $description: String,
+
+};
+
+export interface TemplateCreateSchema {
+ name: string,
+ descriptio?: string,
+}
|