How do I convert this a permission int into an PermissionString[]

Hello, I am watching the GuildAuditLogEntryCreate event and when a permission is updated i am getting this in the entry changes: [ { key: 'permissions', old: 8797166764176, new: 8797166764160 } ], I want to see which permissions has been changes so I hhave seen on the documentation that I can use PermissionsBitsField, I wrote this

if (e.key == 'permissions') {
let oldPerm = new PermissionsBitField(e.old).toArray()
let newPerm = new PermissionsBitField(e.new).toArray()
console.log({ oldPerm, newPerm })
}

if (e.key == 'permissions') {
let oldPerm = new PermissionsBitField(e.old).toArray()
let newPerm = new PermissionsBitField(e.new).toArray()
console.log({ oldPerm, newPerm })
}
But I am getting an error and I dont know what I am doing wrong, thanks for the help RangeError [BitFieldInvalid]: Invalid bitfield flag or number: 8797166764176.
6 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
pןɐnɯoᴚ
pןɐnɯoᴚOP2mo ago
I'm using discord.js v14.16.3 and node v22.8.0
Kinect3000
Kinect30002mo ago
PermissionsBitField takes BigInt, not number
pןɐnɯoᴚ
pןɐnɯoᴚOP2mo ago
how do i convert it into a BigInt?
Kinect3000
Kinect30002mo ago
Not sure why you aren’t even getting it as string Afaik, Discord provides permissions as string Unless ur on an outdated version
pןɐnɯoᴚ
pןɐnɯoᴚOP2mo ago
ok i've try a string instead and it works thx
Want results from more Discord servers?
Add your server