mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 13:14:06 +01:00
Update members.ts
This commit is contained in:
parent
f15e339611
commit
4421db0a71
@ -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, removeMember } from "../../../util/Member";
|
||||
import { PublicMemberProjection, addMember, removeMember, addRole, removeRole } from "../../../util/Member";
|
||||
import { emitEvent } from "../../../util/Event";
|
||||
import { getPublicUser } from "../../../util/User";
|
||||
|
||||
@ -78,5 +78,23 @@ router.delete("/:member", async (req: Request, res: Response) => {
|
||||
// https://discord.com/developers/docs/resources/guild#remove-guild-member
|
||||
});
|
||||
|
||||
router.delete("/:member/roles/:role_id", async (req: Request, res: Response) => {
|
||||
|
||||
const { guild_id, role_id } = req.params;
|
||||
if(!role_id) throw new HTTPError("role_id not defined", 404);
|
||||
|
||||
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 removeRole(user_id, guild_id, role_id);
|
||||
|
||||
// https://discord.com/developers/docs/resources/guild#remove-guild-member-role
|
||||
});
|
||||
|
||||
|
||||
export default router;
|
||||
|
Loading…
Reference in New Issue
Block a user