blob: 77b8d72a37eeff19b8f3fc605cf054fd9963e290 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import { getPermission, PermissionResolvable } from "@fosscord/server-util";
import { Request, Response, Router } from "express";
import { check } from "lambert-server";
import { MemberNickChangeSchema } from "../../../../../schema/Member";
import { changeNickname } from "../../../../../util/Member";
const router = Router();
router.patch("/", check(MemberNickChangeSchema), async (req: Request, res: Response) => {
var { guild_id, member_id } = req.params;
var permissionString: PermissionResolvable = "MANAGE_NICKNAMES";
if (member_id === "@me") {
member_id = req.user_id;
permissionString = "CHANGE_NICKNAME";
}
const perms = await getPermission(req.user_id, guild_id);
perms.hasThrow(permissionString);
await changeNickname(member_id, guild_id, req.body.nick);
res.status(200).send();
});
export default router;
|