summary refs log tree commit diff
diff options
context:
space:
mode:
authorLachlanCourt <lachlan.m.court@gmail.com>2022-07-05 00:19:33 +1000
committerErkin Alp Güney <erkinalp9035@gmail.com>2022-07-04 22:22:43 +0300
commit04f22cbfd0c522770164be3f27c6dffef595e250 (patch)
tree1eff17854d5afca38abf263640e7e61246bb52e2
parentCreate role subdirectory and add GET api route (diff)
downloadserver-04f22cbfd0c522770164be3f27c6dffef595e250.tar.xz
Fix compile error in get request
-rw-r--r--api/src/routes/guilds/#guild_id/roles/#role_id/index.ts46
1 files changed, 4 insertions, 42 deletions
diff --git a/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts b/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts
index 69c2143d..f01b81c9 100644
--- a/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts
@@ -19,52 +19,14 @@ const router = Router();
 router.get("/",route({}), async (req: Request, res: Response) => {
     const { guild_id, role_id } = req.params
     await Member.IsInGuildOrFail(req.user_id, guild_id);
-	const role = await Role.find({ guild_id: guild_id }).find((r: {id: string}) => r.id === role_id);
+	const roles = await Role.find({ guild_id: guild_id })
+    const role = roles.find((r: {id: string}) => r.id === role_id);
 	return res.json(role);
 });
 
-// router.post("/", route({ body: "RoleModifySchema", permission: "MANAGE_ROLES" }), async (req: Request, res: Response) => {
-// 	const guild_id = req.params.guild_id;
-// 	const body = req.body as RoleModifySchema;
-
-// 	const role_count = await Role.count({ guild_id });
-// 	const { maxRoles } = Config.get().limits.guild;
-
-// 	if (role_count > maxRoles) throw DiscordApiErrors.MAXIMUM_ROLES.withParams(maxRoles);
-
-// 	const role = new Role({
-// 		// values before ...body are default and can be overriden
-// 		position: 0,
-// 		hoist: false,
-// 		color: 0,
-// 		mentionable: false,
-// 		...body,
-// 		guild_id: guild_id,
-// 		managed: false,
-// 		permissions: String(req.permission!.bitfield & BigInt(body.permissions || "0")),
-// 		tags: undefined,
-// 		icon: null,
-// 		unicode_emoji: null
-// 	});
-
-// 	await Promise.all([
-// 		role.save(),
-// 		emitEvent({
-// 			event: "GUILD_ROLE_CREATE",
-// 			guild_id,
-// 			data: {
-// 				guild_id,
-// 				role: role
-// 			}
-// 		} as GuildRoleCreateEvent)
-// 	]);
-
-// 	res.json(role);
-// });
 
-// router.delete("/:role_id", route({ permission: "MANAGE_ROLES" }), async (req: Request, res: Response) => {
-// 	const guild_id = req.params.guild_id;
-// 	const { role_id } = req.params;
+// router.delete("/", route({ permission: "MANAGE_ROLES" }), async (req: Request, res: Response) => {
+// 	const { guild_id, role_id } = req.params;
 // 	if (role_id === guild_id) throw new HTTPError("You can't delete the @everyone role");
 
 // 	await Promise.all([