A Discord bitfield library
A JavaScript wrapper for Discord bitflags. You can easily modify Permissions, Intents, User flags, Channel Flags, and more with this library.
Install the library by running
```
npm i discord-bitflag
Then import and use it in your code like this:
`js
import { PermissionFlags, PermissionsBitField } from "discord-bitflag";
const response = await fetch(DISCORD_API, { ...options });
const permissions = new PermissionsBitField(response.permissions);
if (permissions.has(PermissionFlags.BanMembers)) {
console.log("This user can ban members!");
}
if (permissions.has(PermissionsBitField.ALL)) {
console.log("This user has all permissions!");
}
if (permissions.hasWithoutAdmin(PermissionsBitField.ALL)) {
console.log("This user REALLY has all permissions!");
}
`
The Permissions BitField class checks for the Admin permission by default when you check a permission via the .has() method. If you would like to check to see if a permission is explicitly enabled without checking Admin, you can use the .hasWithoutAdmin() method instead.
Each bit field class extends the BitField class from bitflag-js.
- Application Flags: ApplicationFlagsBitField and ApplicationFlagsChannelFlagsBitField
- Channel Flags: and ChannelFlagsGuildMemberFlagsBitField
- Guild Member Flags: and GuildMemberFlagsIntentFlagsBitField
- Intent Flags: and IntentFlagsMessageFlagsBitField
- Message Flags: and MessageFlagsPermissionsBitField
- Permission Flags: and PermissionFlagsUserFlagsBitField
- User Flags: and UserFlags`