mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 20:52:42 +01:00
🐛 fix #392
This commit is contained in:
parent
41f05a5abc
commit
e2a22da5c4
@ -81,10 +81,10 @@ export function route(opts: RouteOptions) {
|
|||||||
return async (req: Request, res: Response, next: NextFunction) => {
|
return async (req: Request, res: Response, next: NextFunction) => {
|
||||||
if (opts.permission) {
|
if (opts.permission) {
|
||||||
const required = new Permissions(opts.permission);
|
const required = new Permissions(opts.permission);
|
||||||
const permission = await getPermission(req.user_id, req.params.guild_id, req.params.channel_id);
|
req.permission = await getPermission(req.user_id, req.params.guild_id, req.params.channel_id);
|
||||||
|
|
||||||
// bitfield comparison: check if user lacks certain permission
|
// bitfield comparison: check if user lacks certain permission
|
||||||
if (!permission.has(required)) {
|
if (!req.permission.has(required)) {
|
||||||
throw DiscordApiErrors.MISSING_PERMISSIONS.withParams(opts.permission as string);
|
throw DiscordApiErrors.MISSING_PERMISSIONS.withParams(opts.permission as string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user