discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.36k stars 3.97k forks source link

Bitfield invalid #4696

Closed artifexdevstuff closed 4 years ago

artifexdevstuff commented 4 years ago

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:

advaith1 commented 4 years ago

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

tipakA commented 4 years ago

"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

artifexdevstuff commented 4 years ago

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?

advaith1 commented 4 years ago

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.

artifexdevstuff commented 4 years ago

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?

NotSugden commented 4 years ago

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?

artifexdevstuff commented 4 years ago

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.

Craftit7 commented 4 years ago

No It happend again @Heroikk Im craftit7 ur collab