🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

discord-bitflag

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-bitflag

A Discord bitfield library

1.0.2
latest
Version published
Weekly downloads
39
-15.22%
Maintainers
0
Weekly downloads
 
Created

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.

FAQs

Package last updated on 24 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts