mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-06 10:52:31 +01:00
MANAGE_GUILDS
This commit is contained in:
parent
be3f796f34
commit
3a5a90007e
@ -1,5 +1,5 @@
|
||||
import { Request, Response, Router } from "express";
|
||||
import { emitEvent, getPermission, Guild, GuildUpdateEvent, handleFile, Member } from "@fosscord/util";
|
||||
import { DiscordApiErrors, emitEvent, getPermission, getRights, Guild, GuildUpdateEvent, handleFile, Member } from "@fosscord/util";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { route } from "@fosscord/api";
|
||||
import "missing-native-js-functions";
|
||||
@ -37,9 +37,17 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
return res.send(guild);
|
||||
});
|
||||
|
||||
router.patch("/", route({ body: "GuildUpdateSchema", permission: "MANAGE_GUILD" }), async (req: Request, res: Response) => {
|
||||
router.patch("/", route({ body: "GuildUpdateSchema"}), async (req: Request, res: Response) => {
|
||||
const body = req.body as GuildUpdateSchema;
|
||||
const { guild_id } = req.params;
|
||||
|
||||
|
||||
const rights = await getRight(req.user_id);
|
||||
const permission = await getPermission(req.user_id, guild_id);
|
||||
|
||||
if (!rights.has("MANAGE_GUILDS")||!permission.has("MANAGE_GUILD"))
|
||||
throw DiscordApiErrors.MISSING_PERMISSIONS("MANAGE_GUILD");
|
||||
|
||||
// TODO: guild update check image
|
||||
|
||||
if (body.icon) body.icon = await handleFile(`/icons/${guild_id}`, body.icon);
|
||||
|
Loading…
Reference in New Issue
Block a user