Improved channelUpdate event logging

This commit is contained in:
Ahmad 2025-03-01 00:11:40 -05:00
parent 6c523bbeba
commit 3762e554b4
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
5 changed files with 295 additions and 16 deletions

View file

@ -84,6 +84,36 @@ export const createPermissionChangeFields = (
return fields;
};
export const getPermissionNames = (
permissions: Readonly<PermissionsBitField>,
): string[] => {
const names: string[] = [];
Object.keys(PermissionsBitField.Flags).forEach((perm) => {
if (permissions.has(perm as keyof typeof PermissionsBitField.Flags)) {
names.push(formatPermissionName(perm));
}
});
return names;
};
export const getPermissionDifference = (
a: Readonly<PermissionsBitField>,
b: Readonly<PermissionsBitField>,
): string[] => {
const names: string[] = [];
Object.keys(PermissionsBitField.Flags).forEach((perm) => {
const permKey = perm as keyof typeof PermissionsBitField.Flags;
if (a.has(permKey) && !b.has(permKey)) {
names.push(formatPermissionName(perm));
}
});
return names;
};
export const createRoleChangeFields = (
oldRole: Partial<RoleProperties>,
newRole: Partial<RoleProperties>,