Socket
Book a DemoInstallSign in
Socket

discord-permission-helper

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-permission-helper

Convert discord permission bitfields to readable strings and check for permissions

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
0
Created
Source

Discord Permission Helper

This npm package provides a simple implementation for converting and checking Discord permission bitfields.

Installation

npm i discord-permission-helper

Example usage

import { PermissionConverter } from 'discord-permission-helper';

// Create a PermissionConverter instance
const permissionConverter = new PermissionConverter();

// Convert a permission bitfield to an array of permission names
const permissionBitfield = '2199023255552n';
const convertedPermissions = permissionConverter.convertPermission({
  hash: permissionBitfield,
  json: false
});

console.log(convertedPermissions);
// Output: ['VIEW_CREATOR_MONETIZATION_ANALYTICS']

// Check if a specific permission is granted in a bitfield
const hasPermission = permissionConverter.checkPermission('KICK_MEMBERS', permissionBitfield);

console.log(hasPermission);
// Output: false

// Convert permissions to JSON string
const jsonPermissions = permissionConverter.convertPermission({
  hash: permissionBitfield,
  json: true
});

console.log(jsonPermissions);
// Output: '["VIEW_CREATOR_MONETIZATION_ANALYTICS"]'

License

MIT

Keywords

discord

FAQs

Package last updated on 14 Oct 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.