skip to Main Content
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: BAN_MEMBERS.
    at PermissionsBitField.resolve (C:UserslukasDesktopbotnode_modulesdiscord.jssrcutilBitField.js:172:11)
    at PermissionsBitField.has (C:UserslukasDesktopbotnode_modulesdiscord.jssrcutilBitField.js:60:28)
    at PermissionsBitField.has (C:UserslukasDesktopbotnode_modulesdiscord.jssrcutilPermissionsBitField.js:92:82)
    at Object.execute (C:UserslukasDesktopbotcommandsutilityserver.js:9:39)
    at Client.<anonymous> (C:UserslukasDesktopbotindex.js:62:17)
    at Client.emit (node:events:513:28)
    at InteractionCreateAction.handle (C:UserslukasDesktopbotnode_modulesdiscord.jssrcclientactionsInteractionCreate.js:97:12)
    at module.exports [as INTERACTION_CREATE] (C:UserslukasDesktopbotnode_modulesdiscord.jssrcclientwebsockethandlersINTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (C:UserslukasDesktopbotnode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:354:31)
    at WebSocketManager.<anonymous> (C:UserslukasDesktopbotnode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:238:12) {
  code: 'BitFieldInvalid'
}

while executing

if (!interaction.member.permissions.has('BAN_MEMBERS')) {
    return interaction.reply('You do not have the required permissions to use this command.');
}

I was trying to make banning command. I’ve added GatewayIntentBits.GuildBans to intents but it says that its deprecated.

2

Answers


  1. In discord.js v14 the permission is called BanMembers.
    You can see all permission names here

    if (!interaction.member.permissions.has('BanMembers')) {
        return interaction.reply('You do not have the required permissions to use this command.');
    }
    
    Login or Signup to reply.
  2. I have found it is better to just by role like this:

    if (!interaction.member.roles.cache.has('someRoleIdHere') || !interaction.member.roles.cache.has('someOtherRoleIdHere')) {
            interaction.reply({ content: 'You do not have permission to use this command', ephemeral: true });
            return;
        }
    

    This is just the way I like to do it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search