How to check if a number (the permission integer) has the manage server permission?

I need to check this, without using discordjs, only the sapphire/bitfield package I didnt understand the readme good enough, thats why im asking here.
Solution:
Solution ```ts const p: bigint = BigInt(guild.permissions); const PermissionsBitField = new BitField(enumToObject(PermissionFlagsBits)); const hasManageGuild =...
Jump to solution
4 Replies
chillihero
chilliheroOP2y ago
from this "permissions": "2147484672",
Favna
Favna2y ago
Go to https://discord.com/developers/applications then your application -> bot and at the bottom you will have a UI of what permission make what bits. sapphire/bitfield will never give discord specific names because it's not a discord -targeted library
kyra
kyra2y ago
Please read bitfield's README, it's a type-safe wrapper like Discord.js's which accepts both names and values The README even has an example using the PermissionsFlagsBits object from -types and how to consume it
Solution
chillihero
chillihero2y ago
Solution
const p: bigint = BigInt(guild.permissions);
const PermissionsBitField = new BitField(enumToObject(PermissionFlagsBits));
const hasManageGuild =
PermissionsBitField.has(p, PermissionFlagsBits.Administrator) || PermissionsBitField.has(p, PermissionFlagsBits.ManageGuild);
const p: bigint = BigInt(guild.permissions);
const PermissionsBitField = new BitField(enumToObject(PermissionFlagsBits));
const hasManageGuild =
PermissionsBitField.has(p, PermissionFlagsBits.Administrator) || PermissionsBitField.has(p, PermissionFlagsBits.ManageGuild);
Want results from more Discord servers?
Add your server