npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

discord_permissions_manager

v1.1.7

Published

A discord command permissions manager

Downloads

87

Readme

🚀 Discord Comamnd Permissions Manager

📦 Installation

Install the npm package into your bot or utility project. It is framework-agnostic and works with any method that sends raw Discord payloads (e.g., REST, Interactions API, libraries like discord.js, harmony, etc.). Originally designed to be used with discord.js.

npm install discord_permissions_manager

✨ Features

  • ✅ Fetch application commands and their permissions
  • ✅ Add, update, or remove individual command permissions
  • ✅ Validate the invoking user's ability to manage command permissions
  • ✅ Automatically resolves role/channel access based on user privileges
  • ✅ Calculate permissions with support for channel overrides and admin bypass

🛠️ Usage Example

import { DiscordPermissionsManager } from './DiscordPermissionsManager';

const manager = new DiscordPermissionsManager({
  applicationId: 'YOUR_APP_ID',
  botToken: 'YOUR_BOT_TOKEN',
  bearerToken: 'YOUR_OAUTH_TOKEN', // This is specifically from a user who authenticated with your bot via OAuth2 with the scope applications.commands.permissions.update
  guildId: 'GUILD_ID',
});

// Add permission to a command
await manager.addCommandPermissions('COMMAND_ID', [
  {
    id: 'ROLE_OR_USER_OR_CHANNEL_ID',
    type: 0, // 1 = Role, 2 = User, 3 = Channel
    permission: true // Whether or not specified item has access
  }
]);

// Set exact list of permissions for a command
await manager.setCommandPermissions('COMMAND_ID', [
  {
    id: 'ROLE_OR_USER_OR_CHANNEL_ID',
    type: 0, // 1 = Role, 2 = User, 3 = Channel
    permission: true // Whether or not specified item has access
  }
]);

// Remove specific item from permission overwrites for a command
await manager.removeCommandPermission('COMMAND_ID', [
  {
    id: 'ROLE_OR_USER_OR_CHANNEL_ID',
    type: 0, // 1 = Role, 2 = User, 3 = Channel
  }
]);

// List current permission overwrites of a command
const permissions = await manager.getCommandPermissions('COMMAND_ID');
// Expected output: [ { id: 'ROLE_OR_USER_OR_CHANNEL_ID', type: 0, permission: true } ]

// Check if a command is managable by the authenticated user
const managable = await manager.validateCommandPermissionAccess('COMMAND_ID');
// Expected output: true if successful or error if failed

// Return a list of all roles, channels, and commands that the authenticated user can manage (very important to check since if they can't manage a specific role or channel then they can't set overwrites on any command for said item)
const resources = await manager.getAvailableManageableResources();
// Expected output: { roles, channels, commands }

📘 API

new DiscordPermissionsManager(options) Creates a new manager instance.

Options:

  • applicationId: Discord Application ID
  • botToken: Bot token (Bot ...)
  • bearerToken: OAuth2 token with required scopes (Bearer ...)
  • guildId: Target guild ID

🔍 Core Methods

getCommandPermissions(commandId) Returns current permissions for the given command.

addCommandPermissions(commandId, permissions[]) Merges and sets new permissions for the command.

removeCommandPermission(commandId, targetId, type) Removes a specific permission entry (role or user).

setCommandPermissions(commandId, permissions[]) Directly sets the permissions list (replaces existing).

validateCommandPermissionAccess(commandId) Throws an error if the current user is not allowed to manage the command.

getAvailableManageableResources() Returns all roles, channels, and commands that the current user can manage.

🔐 Permission Logic

  • Guild owners always have full access.
  • Admin roles bypass all restrictions.
  • Role hierarchy and Discord permission flags (e.g., ManageGuild, ManageRoles) are enforced.
  • Channel-level permission overwrites are considered when evaluating channel access.

🧾 License

Custom MIT, refer to LICENSE file © Golden Development