mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
calculatePermissions should take a string
This commit is contained in:
@@ -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),
|
||||
})),
|
||||
};
|
||||
|
||||
|
||||
@@ -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[];
|
||||
|
||||
Reference in New Issue
Block a user