v14.14.1: RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.

i get the above error when i run this command on my bot: "/setmodpackid modpack_id: 925200"
// Define the /setmodpackid command
bot.on('interactionCreate', async interaction => {
if (!interaction.isCommand() || interaction.commandName !== 'setmodpackid') return;

// Check if the user has administrator permissions
if (!interaction.member.permissions.has(GatewayIntentBits.GuildMembers.MANAGE_GUILD) && interaction.user.id !== ownerId) {
return await interaction.reply('You do not have permission to use this command.');
}

const modpackId = interaction.options.getInteger('modpack_id');
await saveSettings(interaction.guildId, 'modpackid', modpackId);
await interaction.reply(`Modpack ID set to ${modpackId}.`);
});
// Define the /setmodpackid command
bot.on('interactionCreate', async interaction => {
if (!interaction.isCommand() || interaction.commandName !== 'setmodpackid') return;

// Check if the user has administrator permissions
if (!interaction.member.permissions.has(GatewayIntentBits.GuildMembers.MANAGE_GUILD) && interaction.user.id !== ownerId) {
return await interaction.reply('You do not have permission to use this command.');
}

const modpackId = interaction.options.getInteger('modpack_id');
await saveSettings(interaction.guildId, 'modpackid', modpackId);
await interaction.reply(`Modpack ID set to ${modpackId}.`);
});
to me this error doesn't make sense
9 Replies
d.js toolkit
d.js toolkit6mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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!
Minecrafter
MinecrafterOP6mo ago
here is the full error log from pm2
0|botv2 | (node:147086) DeprecationWarning: BaseInteraction#isSelectMenu() is deprecated. Use BaseInteraction#isStringSelectMenu() instead.
0|botv2 | (Use `node --trace-deprecation ...` to show where the warning was created)
0|botv2 | RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
0|botv2 | at PermissionsBitField.resolve (/home/server/ATM9-discordbot/node_modules/discord.js/src/util/BitField.js:174:11)
0|botv2 | at PermissionsBitField.has (/home/server/ATM9-discordbot/node_modules/discord.js/src/util/BitField.js:60:28)
0|botv2 | at PermissionsBitField.has (/home/server/ATM9-discordbot/node_modules/discord.js/src/util/PermissionsBitField.js:92:82)
0|botv2 | at Client.<anonymous> (/home/server/ATM9-discordbot/botv2.js:169:41)
0|botv2 | at Client.emit (node:events:530:35)
0|botv2 | at InteractionCreateAction.handle (/home/server/ATM9-discordbot/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
0|botv2 | at module.exports [as INTERACTION_CREATE] (/home/server/ATM9-discordbot/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
0|botv2 | at WebSocketManager.handlePacket (/home/server/ATM9-discordbot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
0|botv2 | at WebSocketManager.<anonymous> (/home/server/ATM9-discordbot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
0|botv2 | at WebSocketManager.emit (/home/server/ATM9-discordbot/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:285:31) {
0|botv2 | code: 'BitFieldInvalid'
0|botv2 | }
PM2 | App [botv2:0] exited with code [1] via signal [SIGINT]
PM2 | App [botv2:0] starting in -fork mode-
PM2 | App [botv2:0] online
0|botv2 | Started refreshing application (/) commands.
0|botv2 | Successfully reloaded application (/) commands.
0|botv2 | Starting bot...
0|botv2 | Bot started
0|botv2 | (node:147086) DeprecationWarning: BaseInteraction#isSelectMenu() is deprecated. Use BaseInteraction#isStringSelectMenu() instead.
0|botv2 | (Use `node --trace-deprecation ...` to show where the warning was created)
0|botv2 | RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
0|botv2 | at PermissionsBitField.resolve (/home/server/ATM9-discordbot/node_modules/discord.js/src/util/BitField.js:174:11)
0|botv2 | at PermissionsBitField.has (/home/server/ATM9-discordbot/node_modules/discord.js/src/util/BitField.js:60:28)
0|botv2 | at PermissionsBitField.has (/home/server/ATM9-discordbot/node_modules/discord.js/src/util/PermissionsBitField.js:92:82)
0|botv2 | at Client.<anonymous> (/home/server/ATM9-discordbot/botv2.js:169:41)
0|botv2 | at Client.emit (node:events:530:35)
0|botv2 | at InteractionCreateAction.handle (/home/server/ATM9-discordbot/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
0|botv2 | at module.exports [as INTERACTION_CREATE] (/home/server/ATM9-discordbot/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
0|botv2 | at WebSocketManager.handlePacket (/home/server/ATM9-discordbot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
0|botv2 | at WebSocketManager.<anonymous> (/home/server/ATM9-discordbot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
0|botv2 | at WebSocketManager.emit (/home/server/ATM9-discordbot/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:285:31) {
0|botv2 | code: 'BitFieldInvalid'
0|botv2 | }
PM2 | App [botv2:0] exited with code [1] via signal [SIGINT]
PM2 | App [botv2:0] starting in -fork mode-
PM2 | App [botv2:0] online
0|botv2 | Started refreshing application (/) commands.
0|botv2 | Successfully reloaded application (/) commands.
0|botv2 | Starting bot...
0|botv2 | Bot started
treble/luna
treble/luna6mo ago
gatewayintentbits arent permissions
Minecrafter
MinecrafterOP6mo ago
what is?
treble/luna
treble/luna6mo ago
did you ask ai to write that code
Minecrafter
MinecrafterOP6mo ago
does that effect if you can help me or not?
treble/luna
treble/luna6mo ago
It does Because you have 0 clue what that code does and what is wrong with it If you just follow the guide and docs you wouldnt have this issue
d.js docs
d.js docs6mo ago
:dtypes: v10: PermissionFlagsBits read more
treble/luna
treble/luna6mo ago
Thats the correct enum
Want results from more Discord servers?
Add your server