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
In discord.js v14 the permission is called
BanMembers
.You can see all permission names here
I have found it is better to just by role like this:
This is just the way I like to do it.