summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorIntevel ツ <59223342+Intevel@users.noreply.github.com>2021-05-04 11:39:44 +0200
committerIntevel ツ <59223342+Intevel@users.noreply.github.com>2021-05-04 11:39:44 +0200
commit4a61f250c9c0651256a66b54d2dcd55ff371d19a (patch)
tree2330a1a3afa40cd543435e9ec965972f6ec2c52e /src
parent[Route] PUT /guilds/:id/members (diff)
downloadserver-4a61f250c9c0651256a66b54d2dcd55ff371d19a.tar.xz
[ROUTE] DELETE /guilds/:id/members
Not tested
Diffstat (limited to 'src')
-rw-r--r--src/routes/guilds/#guild_id/members.ts18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/routes/guilds/#guild_id/members.ts b/src/routes/guilds/#guild_id/members.ts
index faba269c..5567912c 100644
--- a/src/routes/guilds/#guild_id/members.ts
+++ b/src/routes/guilds/#guild_id/members.ts
@@ -2,7 +2,7 @@ import { Request, Response, Router } from "express";
 import { GuildModel, MemberModel, UserModel, toObject, GuildMemberAddEvent } from "@fosscord/server-util";
 import { HTTPError } from "lambert-server";
 import { instanceOf, Length } from "../../../util/instanceOf";
-import { PublicMemberProjection, addMember } from "../../../util/Member";
+import { PublicMemberProjection, addMember, removeMember } from "../../../util/Member";
 import { emitEvent } from "../../../util/Event";
 import { getPublicUser } from "../../../util/User";
 
@@ -62,4 +62,20 @@ router.put("/:member", async (req: Request, res: Response) => {
 	// https://discord.com/developers/docs/resources/guild#add-guild-member
 });
 
+
+router.delete("/:member", async (req: Request, res: Response) => {
+	const { guild_id } = req.params;
+	const guild = await GuildModel.findOne({ id: guild_id }).exec();
+	if (!guild) throw new HTTPError("Guild not found", 404);
+
+	const user_id = req.params.member;
+
+	const member = await MemberModel.findOne({ id: user_id, guild_id }).exec();
+	if (!member) throw new HTTPError("Member not found", 404);
+
+	await removeMember(user_id, guild_id);
+
+	// https://discord.com/developers/docs/resources/guild#remove-guild-member
+});
+
 export default router;