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

8 messages · Page 1 of 1 (latest)

wanton roost
#

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 })
}

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.

valid lintelBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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
wanton roost
#

I'm using discord.js v14.16.3 and node v22.8.0

median gulch
#

PermissionsBitField takes BigInt, not number

wanton roost
#

how do i convert it into a BigInt?

median gulch
#

Not sure why you aren’t even getting it as string

#

Afaik, Discord provides permissions as string

#

Unless ur on an outdated version