Discord.js: Bitfield invalid

Created on 13 Aug 2020  路  8Comments  路  Source: discordjs/discord.js

Im trying to run a simple "ping" command which reutrns ''pong'' with the latency.
Here is the block im using:

client.on('message', msg => {
  let args = msg.content.substring(prefix.length).split(" ");

  switch (args[0]) {
    case 'ping':
    var ping = Math.round(client.ws.ping);
    msg.channel.send({embed: {
      color: 3447003,
      title: "Pong! :ping_pong:",
      description: "Bot ping is " + ping +'ms',
    }})
};
});

Here is the error im getting:

RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.
    at Function.resolve (C:\Users\admin\node_modules\discord.js\src\util\BitField.js:150:11)
    at Permissions.has (C:\Users\admin\node_modules\discord.js\src\util\BitField.js:45:28)
    at Permissions.has (C:\Users\admin\node_modules\discord.js\src\util\Permissions.js:45:85)
    at C:\Users\admin\node_modules\discord.js\src\structures\GuildMember.js:268:53
    at Map.some (C:\Users\admin\node_modules\@discordjs\collection\dist\index.js:235:17)
    at GuildMember.hasPermission (C:\Users\admin\node_modules\discord.js\src\structures\GuildMember.js:268:29)
    at Client.<anonymous> ([stdin]:37:19)
    at Client.emit (events.js:327:22)
    at MessageCreateAction.handle (C:\Users\admin\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\admin\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) {
  [Symbol(code)]: 'BITFIELD_INVALID'
}

Further details:

  • discord.js version: 12.2.0
  • Node.js version: 12.18.3
  • Operating system: Windows
unverified bug

Most helpful comment

the error seems to indicate you are calling GuildMember.hasPermission in your code, but the example you provided does not, are you sure you aren't calling GuildMember.hasPermission somewhere else?

All 8 comments

馃 what are your ClientOptions? sounds like you might be using API v8 instead of v6/7 (which discord.js does not support)

"Latest master branch" does not tell anything at all, since master branch has code changes very often, and still is "lastest master" That's especially the case since yesterday.
Additionally, looking on error stack and source code, you do not have "latest" master.

EDIT: found that this is on commit 3df9993 or older

what are your ClientOptions? sounds like you might be using API v8 instead of v6/7 (which discord.js does not support)

How do I know which API version I'm using?

unless you explicitly set it in your clientoptions then it should default to v7

try updating to the latest commit; if that doesn't work when try to find reproducible code that leads to this, or anything weird you're doing with permissions that might cause issues.

unless you explicitly set it in your clientoptions then it should default to v7

try updating to the latest commit; if that doesn't work when try to find reproducible code that leads to this, or anything weird you're doing with permissions that might cause issues.

I used npm install discord.js to install it. How can I update that?

the error seems to indicate you are calling GuildMember.hasPermission in your code, but the example you provided does not, are you sure you aren't calling GuildMember.hasPermission somewhere else?

the error seems to indicate you are calling GuildMember.hasPermission in your code, but the example you provided does not, are you sure you aren't calling GuildMember.hasPermission somewhere else?

Yes i am sure.

EDIT: It was my installation of the library. I reinstalled it and everything is working now.

No It happend again @Heroikk Im craftit7 ur collab

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DatMayo picture DatMayo  路  3Comments

Brawaru picture Brawaru  路  3Comments

Dmitry221060 picture Dmitry221060  路  3Comments

shukriadams picture shukriadams  路  3Comments

ghost picture ghost  路  3Comments