calculatePermissions should take a string

This commit is contained in:
ITOH
2021-04-30 15:13:58 +02:00
parent 5b314d0b9e
commit a7de104b9a
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -29,8 +29,8 @@ export async function cloneChannel(channelId: string, reason?: string) {
) => ({ ) => ({
id: overwrite.id, id: overwrite.id,
type: overwrite.type, type: overwrite.type,
allow: calculatePermissions(BigInt(overwrite.allow)), allow: calculatePermissions(overwrite.allow),
deny: calculatePermissions(BigInt(overwrite.deny)), deny: calculatePermissions(overwrite.deny),
})), })),
}; };
+2 -2
View File
@@ -268,13 +268,13 @@ export function requireBotChannelPermissions(
} }
/** This function converts a bitwise string to permission strings */ /** This function converts a bitwise string to permission strings */
export function calculatePermissions(permissionBits: bigint) { export function calculatePermissions(permissionBits: string) {
return Object.keys(DiscordBitwisePermissionFlags).filter((permission) => { return Object.keys(DiscordBitwisePermissionFlags).filter((permission) => {
// Since Object.keys() not only returns the permission names but also the bit values we need to return false if it is a Number // Since Object.keys() not only returns the permission names but also the bit values we need to return false if it is a Number
if (Number(permission)) return false; if (Number(permission)) return false;
// Check if permissionBits has this permission // Check if permissionBits has this permission
return ( return (
permissionBits & BigInt(permissionBits) &
BigInt(DiscordBitwisePermissionFlags[permission as PermissionStrings]) BigInt(DiscordBitwisePermissionFlags[permission as PermissionStrings])
); );
}) as PermissionStrings[]; }) as PermissionStrings[];