Skip to content

PermissionSet

PermissionSet (also exported as PermissionsBitField for Discord.js compatibility) provides named permission checks against Discord’s 64-bit permission bitfield.

import { PermissionSet, Permission } from "lunibee";
// Discord.js-style alias:
import { PermissionsBitField } from "lunibee";
new PermissionSet(bits: bigint | string | number = 0n)
const perms = new PermissionSet(member.permissions.bits);
Property Type Description
bits bigint The raw bitfield as a BigInt.

Returns true if the bitfield contains the given permission. Accepts a Permission constant, a bigint, or a camelCase/PascalCase permission name string.

if (member.permissions.has(Permission.manageMessages)) {
// allowed
}
// Also works with string keys:
if (member.permissions.has("manageMessages")) {
// allowed
}

Returns true only if all of the given permissions are present.

if (member.permissions.hasAll(Permission.banMembers, Permission.kickMembers)) {
console.log("Has both ban and kick.");
}

Returns true if at least one of the given permissions is present.

Returns true if the administrator permission is set.

if (member.permissions.isAdministrator()) {
// full access
}

Returns a new PermissionSet with the given permissions added (immutable).

const updated = perms.add(Permission.sendMessages, Permission.readMessageHistory);

Returns a new PermissionSet with the given permissions removed (immutable).

const restricted = perms.remove(Permission.manageMessages);

Returns an array of all active permission names.

const permNames = member.permissions.toArray();
// → ["viewChannel", "sendMessages", "readMessageHistory", ...]

Returns the bitfield as a decimal string (useful for API payloads).

const payload = { permissions: member.permissions.toString() };

All Permission keys use camelCase. A Permissions (PascalCase) alias is also available.

Key Bit
createInstantInvite 1 << 0
kickMembers 1 << 1
banMembers 1 << 2
administrator 1 << 3
manageChannels 1 << 4
manageGuild 1 << 5
addReactions 1 << 6
viewAuditLog 1 << 7
viewChannel 1 << 10
sendMessages 1 << 11
manageMessages 1 << 13
embedLinks 1 << 14
attachFiles 1 << 15
readMessageHistory 1 << 16
mentionEveryone 1 << 17
connect 1 << 20
speak 1 << 21
muteMembers 1 << 22
deafenMembers 1 << 23
moveMembers 1 << 24
manageRoles 1 << 28
manageWebhooks 1 << 29
manageEvents 1 << 33
manageThreads 1 << 34
moderateMembers 1 << 40
sendPolls 1 << 49

(and more — see packages/core/src/permissions.ts for the full list)

Permission gate in a command

import { Permission } from "lunibee";
client.on("interactionCreate", async (interaction) => {
if (!interaction.isChatInputCommand() || interaction.commandName !== "ban") return;
if (!interaction.member?.permissions.has(Permission.banMembers)) {
return interaction.reply({ content: "You need the Ban Members permission.", ephemeral: true });
}
// proceed with ban...
});

Build a permissions embed

const activePerms = member.permissions.toArray();
const embed = new EmbedBuilder()
.setTitle("Your Permissions")
.setDescription(activePerms.map(p => `${p}`).join("\n") || "None");
await interaction.reply({ embeds: [embed], ephemeral: true });