mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 05:02:37 +01:00
🐛 fix #392
This commit is contained in:
parent
6229398316
commit
a83c9fe510
@ -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