Skip to content

MCStatusBot/bitfieldcalulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCStatus Bot Bitfield Calculator

This NPM package provides a utility for calculating bitfields for our permissions you can grant on things like mcservers and api tokens.

Usage

Here are some examples:

Copy code
const MCStatusBotBitfieldCalulator = require('mcstatusbot-bitfieldcalulator')

const bitfield = 17;
//get permissions from a bitfield in an array
const permissionsArray = MCStatusBotBitfieldCalulator.permissions(bitfield)
console.log(permissionsArray);
//see if member has certain permission
console.log("can create Minecraft servers: " + MCStatusBotBitfieldCalulator.has('CREATE_MINECRAFT_SERVER'));
//or you can do
console.log("can create Minecraft servers: " + permissionsArray.includes('CREATE_MINECRAFT_SERVER'));

//get a bitfield from a permissions array
const bitfield = MCStatusBotBitfieldCalulator.bitfield(["CREATE_MINECRAFT_SERVER", "DELETE_MINECRAFT_SERVER", "CREATE_CHANNEL_WATCHER"])
console.log(bitfield);

Methods

MCStatusBotBitfieldCalulator.permissions(bitfield: Int) Returns an array of permissions obtained from a bitfield.

MCStatusBotBitfieldCalulator.bitfield(permissions: Array) Returns a bitfield calculated from an array of permissions.

MCStatusBotBitfieldCalulator.has(permission: String) Checks if a user has a specific permission and returns a boolean value.

License This package is licensed under the MIT license. See the LICENSE file for more information.

About

calculate the bitfields for our api

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published