npm install discord-bitfield-calculator
your js file
const bitfieldCalculator = require('discord-bitfield-calculator');
//the bitfield you get from some discord endpoint
const myBitfield = 523016588865;
//get the array returned and make it a varible
const myPerms = bitfieldCalculator.permissions(myBitfield);
//do as you wish with the array or permissions
console.log(myPerms);
if(myPerms.includes('BAN_MEMBERS')) {
console.log("this bitfield contains the permission to ban members.");
} else {
console.log("this bitfield doesn't contains the permission to ban members.");
}
permissions(bitfield)
- returns an array of permissions that can be found here.
bitfield('PERMISSION')
- returns the bitfield value for that permission.