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,
type: overwrite.type,
allow: calculatePermissions(BigInt(overwrite.allow)),
deny: calculatePermissions(BigInt(overwrite.deny)),
allow: calculatePermissions(overwrite.allow),
deny: calculatePermissions(overwrite.deny),
})),
};
+2 -2
View File
@@ -268,13 +268,13 @@ export function requireBotChannelPermissions(
}
/** 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) => {
// 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;
// Check if permissionBits has this permission
return (
permissionBits &
BigInt(permissionBits) &
BigInt(DiscordBitwisePermissionFlags[permission as PermissionStrings])
);
}) as PermissionStrings[];