mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 09:39:09 +00:00
chore: update prettier tab width for consistency (#175)
This commit is contained in:
parent
a931f8c69c
commit
f24d2fcc99
247 changed files with 7224 additions and 7375 deletions
|
@ -1,55 +1,55 @@
|
|||
import { Role } from '@roleypoly/types';
|
||||
|
||||
export const evaluatePermission = <T extends number | bigint>(
|
||||
haystack: T,
|
||||
needle: T
|
||||
haystack: T,
|
||||
needle: T
|
||||
): boolean => {
|
||||
return (haystack & needle) === needle;
|
||||
return (haystack & needle) === needle;
|
||||
};
|
||||
|
||||
export const hasPermission = (roles: Role[], permission: bigint): boolean => {
|
||||
const aggregateRoles = roles.reduce(
|
||||
(acc, role) => acc | BigInt(role.permissions),
|
||||
BigInt(0)
|
||||
);
|
||||
return evaluatePermission(aggregateRoles, permission);
|
||||
const aggregateRoles = roles.reduce(
|
||||
(acc, role) => acc | BigInt(role.permissions),
|
||||
BigInt(0)
|
||||
);
|
||||
return evaluatePermission(aggregateRoles, permission);
|
||||
};
|
||||
|
||||
export const hasPermissionOrAdmin = (roles: Role[], permission: bigint): boolean =>
|
||||
hasPermission(roles, permission | permissions.ADMINISTRATOR);
|
||||
hasPermission(roles, permission | permissions.ADMINISTRATOR);
|
||||
|
||||
export const permissions = {
|
||||
// IMPORTANT: Only uncomment what's actually used. All are left for convenience.
|
||||
// IMPORTANT: Only uncomment what's actually used. All are left for convenience.
|
||||
|
||||
// CREATE_INSTANT_INVITE: BigInt(0x1),
|
||||
// KICK_MEMBERS: BigInt(0x2),
|
||||
// BAN_MEMBERS: BigInt(0x4),
|
||||
ADMINISTRATOR: BigInt(0x8),
|
||||
// MANAGE_CHANNELS: BigInt(0x10),
|
||||
// MANAGE_GUILD: BigInt(0x20),
|
||||
// ADD_REACTIONS: BigInt(0x40),
|
||||
// VIEW_AUDIT_LOG: BigInt(0x80),
|
||||
// VIEW_CHANNEL: BigInt(0x400),
|
||||
// SEND_MESSAGES: BigInt(0x800),
|
||||
// SEND_TTS_MESSAGES: BigInt(0x1000),
|
||||
// MANAGE_MESSAGES: BigInt(0x2000),
|
||||
// EMBED_LINKS: BigInt(0x4000),
|
||||
// ATTACH_FILES: BigInt(0x8000),
|
||||
// READ_MESSAGE_HISTORY: BigInt(0x10000),
|
||||
// MENTION_EVERYONE: BigInt(0x20000),
|
||||
// USE_EXTERNAL_EMOJIS: BigInt(0x40000),
|
||||
// VIEW_GUILD_INSIGHTS: BigInt(0x80000),
|
||||
// CONNECT: BigInt(0x100000),
|
||||
// SPEAK: BigInt(0x200000),
|
||||
// MUTE_MEMBERS: BigInt(0x400000),
|
||||
// DEAFEN_MEMBERS: BigInt(0x800000),
|
||||
// MOVE_MEMBERS: BigInt(0x1000000),
|
||||
// USE_VAD: BigInt(0x2000000),
|
||||
// PRIORITY_SPEAKER: BigInt(0x100),
|
||||
// STREAM: BigInt(0x200),
|
||||
// CHANGE_NICKNAME: BigInt(0x4000000),
|
||||
// MANAGE_NICKNAMES: BigInt(0x8000000),
|
||||
MANAGE_ROLES: BigInt(0x10000000),
|
||||
// MANAGE_WEBHOOKS: BigInt(0x20000000),
|
||||
// MANAGE_EMOJIS: BigInt(0x40000000),
|
||||
// CREATE_INSTANT_INVITE: BigInt(0x1),
|
||||
// KICK_MEMBERS: BigInt(0x2),
|
||||
// BAN_MEMBERS: BigInt(0x4),
|
||||
ADMINISTRATOR: BigInt(0x8),
|
||||
// MANAGE_CHANNELS: BigInt(0x10),
|
||||
// MANAGE_GUILD: BigInt(0x20),
|
||||
// ADD_REACTIONS: BigInt(0x40),
|
||||
// VIEW_AUDIT_LOG: BigInt(0x80),
|
||||
// VIEW_CHANNEL: BigInt(0x400),
|
||||
// SEND_MESSAGES: BigInt(0x800),
|
||||
// SEND_TTS_MESSAGES: BigInt(0x1000),
|
||||
// MANAGE_MESSAGES: BigInt(0x2000),
|
||||
// EMBED_LINKS: BigInt(0x4000),
|
||||
// ATTACH_FILES: BigInt(0x8000),
|
||||
// READ_MESSAGE_HISTORY: BigInt(0x10000),
|
||||
// MENTION_EVERYONE: BigInt(0x20000),
|
||||
// USE_EXTERNAL_EMOJIS: BigInt(0x40000),
|
||||
// VIEW_GUILD_INSIGHTS: BigInt(0x80000),
|
||||
// CONNECT: BigInt(0x100000),
|
||||
// SPEAK: BigInt(0x200000),
|
||||
// MUTE_MEMBERS: BigInt(0x400000),
|
||||
// DEAFEN_MEMBERS: BigInt(0x800000),
|
||||
// MOVE_MEMBERS: BigInt(0x1000000),
|
||||
// USE_VAD: BigInt(0x2000000),
|
||||
// PRIORITY_SPEAKER: BigInt(0x100),
|
||||
// STREAM: BigInt(0x200),
|
||||
// CHANGE_NICKNAME: BigInt(0x4000000),
|
||||
// MANAGE_NICKNAMES: BigInt(0x8000000),
|
||||
MANAGE_ROLES: BigInt(0x10000000),
|
||||
// MANAGE_WEBHOOKS: BigInt(0x20000000),
|
||||
// MANAGE_EMOJIS: BigInt(0x40000000),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue