1.0.1 • Published 6 months ago

discord-bitflag v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

discord-bitflag

A JavaScript wrapper for Discord bitflags. You can easily modify Permissions, Intents, User flags, Channel Flags, and more with this library.

Usage

Install the library by running

npm i discord-bitflag

Then import and use it in your code like this:

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!");
}

Permissions API

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.

Bit Fields

Each bit field class extends the BitField class from bitflag-js.

1.0.1

6 months ago

1.0.0

9 months ago

0.0.1

10 months ago