#getting permission name from bitfield

1 messages · Page 1 of 1 (latest)

weak dock
blissful parcel
#

As far as I know, no you would have to create one yourself

#

@weak dock

#

Try salvaging some of this I have:

function getPermsNames(flags) {
  const permEntries = Object.entries(Permissions.FLAGS);
  const result = [];
  for (let [ name, flag ] of permEntries) {
    if (flags & flag === 0) continue;
    result.push(name);
  }
  return result;
}
weak dock
#

yeah i have working code that gets me permission name from table of permission names that i did

#

but i'm trying to figure out if there is a simpler way

winter fulcrum
#

How are you defining your initial permission(s)?

weak dock
#
const permissions = log.target.permissionOverwrites.cache;

        permissions.forEach((permission) => {
            console.log(permission.allow.bitfield)
            
        });```
winter fulcrum
#

The method you're looking for here is <Permissions>.toArray()

#

In your case, permission.allow.toArray() will give you ['SEND_MESSAGES', 'VEW_CHANNEL', ...] etc.