Invalid bitfield flag or number: undefined - discord.js

So i went to start my discord.js bot and then this error shown.
throw new RangeError('BITFIELD_INVALID', bit);
^
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: undefined.
at Function.resolve (/home/container/node_modules/discord.js/src/util/BitField.js:152:11)
at /home/container/node_modules/discord.js/src/util/BitField.js:147:54
at Array.map (<anonymous>)
at Function.resolve (/home/container/node_modules/discord.js/src/util/BitField.js:147:40)
at Client._validateOptions (/home/container/node_modules/discord.js/src/client/Client.js:546:33)
at new Client (/home/container/node_modules/discord.js/src/client/Client.js:73:10)
at Object.<anonymous> (/home/container/index.js:4:16)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
[Symbol(code)]: 'BITFIELD_INVALID'}
Can anyone help at all, a list of my commands can be found at https://github.com/Makuta24/commands
Thanks in advance! Ps i do not know what code made this error occur therefor i linked all of the commands on the server, sorry.

An error I noticed on your code, is that you are requesting permissions with the hasPermission() modal. In v13 (version I suppose you are using), this modal is deprecated.
Here is a solution that may work for you:
const { MessageEmbed, Permissions } = require('discord.js');
if (!message.member.permissions.has([Permissions.FLAGS.MANAGE_CHANNELS])) {
return message.channel.send('Wait, you cannot lock channels!')
}
What I am doing here is requesting the Permissions object from the Discord.js library, to use it with your chosen flag (FLAGS.MANAGE_CHANNELS), and then checking if it has the flag you expect with the has() modal.
This is only what I saw on the command's code, though. Your error log shows an error on index.js:4:16, so it may be a good idea to share your index.js file to see if there are other errors present on it.

Related

How do I find where 'given node is not an Element, the node type is: string' error occurred from stack trace? (react/JS)

I'm writing a react app as a practice and I get the following error on several components, however I can't see that it tells me where it comes from? It doesn't prevent tests (jest/react testing library) passing or indeed build (WIP app is successfully deployed to netlify). Nevertheless, I'd like to track it down if only for understanding:
Error: The given node is not an Element, the node type is: string.
at getWindowFromNode (/Users/learning/Documents/projects/mol-bio-tools/node_modules/#testing-library/dom/dist/helpers.js:58:11)
at hasPointerEvents (/Users/learning/Documents/projects/mol-bio-tools/node_modules/#testing-library/user-event/dist/utils/misc/hasPointerEvents.js:11:49)
at click (/Users/learning/Documents/projects/mol-bio-tools/node_modules/#testing-library/user-event/dist/click.js:116:63)
at typeImplementation (/Users/learning/Documents/projects/mol-bio-tools/node_modules/#testing-library/user-event/dist/type/typeImplementation.js:24:36)
at Object.type (/Users/learning/Documents/projects/mol-bio-tools/node_modules/#testing-library/user-event/dist/type/index.js:27:60)
at Object.<anonymous> (/Users/learning/Documents/projects/mol-bio-tools/src/__tests__/transcribe.test.js:33:15)
at Promise.then.completed (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/utils.js:391:28)
at new Promise (<anonymous>)
at callAsyncCircusFn (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/utils.js:316:10)
at _callCircusTest (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/run.js:218:40)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at _runTest (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/run.js:155:3)
at _runTestsForDescribeBlock (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/run.js:66:9)
at _runTestsForDescribeBlock (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/run.js:60:9)
at run (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/run.js:25:3)
at runAndTransformResultsToJestFormat (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:170:21)
at jestAdapter (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:82:19)
at runTestInternal (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-runner/build/runTest.js:389:16)
at runTest (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-runner/build/runTest.js:475:34)
at Object.worker (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-runner/build/testWorker.js:133:12)
Current complete code is here and live app is here (again: WIP - I know various links/etc don't work yet).
Turns out if I actually read that trace it highlights an error in my test:
at Object.<anonymous> (/Users/learning/Documents/projects/mol-bio-tools/src/__tests__/transcribe.test.js:33:15)
Turns out I'd managed to use a hybrid of #testing-library/userevent v13.5 and v14 syntax, and there are breaking changes between the 2 versions. Updated to v14, updated syntax, all good.

I've been stuck with this error for like 2 weeks, I still haven't managed to fix it

So I have updated my help command so that way the menu will be much cleaner and more up to date than my old one. However whenever I replace my old code with my new one I end up getting this Error and I can't seem to figure it out. I've tried commenting out different pieces of my command handler to see whether that fixes it but I had no luck. I've never had this before though. cmd.execute(bot, message, args) is only in the message.js event file apart from the handler. but even when I add that line of code into the file, it doesn't remove the error? it works fine on my old help code though. I also logged cmd in the command.js file in the handler after I defined cmd and it logs all the cmd info right above the error.
I have the cmd.execute(args, message, bot) that is being logged saying that I need it further down under where I define cmd in the help file, its the only file that is throwing the issue and it only happens if I use the new help.js menu.
Error:
TypeError: [ERROR][COMMANDS]: execute function is required for commands! (help.js)
at /home/runner/RocketBot/utils/command.js:18:15
at Array.forEach (<anonymous>)
at module.exports (/home/runner/RocketBot/utils/command.js:8:23)
at Object.<anonymous> (/home/runner/RocketBot/index.js:19:30)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:132)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
Files
Old Help Command: https://hasteb.in/tuhiduvi.js
New Help Command: https://hasteb.in/awiyafap.js
command.js: https://hasteb.in/ebuduyuv.js
message.js: https://hasteb.in/oviwuvix.js

Trying to make add Autorole to my bot but get TypeError: fn.bind is not a function

I'm new to coding javascript and I'm coding discord.js. I've been trying to add an auto role feature so that when someone joins the discord server they automatically obtain the default role. However, I've been struggling as all the tutorials or other code explaining it is usually out-dated. So when I try and run the bot I get this error message.
TypeError: fn.bind is not a function
at Map.find (C:\Users\stuar\Desktop\Discord Bot\node modulesN^discordjs\collection\dist\index.js:158:21) at Client.<anonymous> (C:\Users\stuar\Desktop\Discord Bot\index.js:71:41)
at Client.emit (events.js:327:22)
at Object.module.exports [as GUILD_MEMBER_ADD] (C:\Users\stuar\Desktop\Discord Bot\node modules\discord.js\src\client\websocket\handlers\GUILD MEMBER ADD.js:16:14)
at WebSocketManager. handlePacket (C : \Users\stuar\Desktop\Discord Bot \node_modules\discordjs\src\client \websocket \WebSocketManager. j s : 386:31 )
at WebSocketShard.onPacket (C:\Users\stuar\Desktop\Discord Bot\node modules\discord.j s\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\stuar\Desktop\Discord Bot\node modules\discord.js\src\client\websocket\WebSocketShard.js: 293:10)
at WebSocket.onMessage (C:\Users\stuar\Desktop\Discord Bot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:29)
at Receiver.receiverOnMessage (C:\Users\stuar\Desktop\Discord Bot\node_modules\ws\lib\websocket.js: 800:20)
And this is my code that it seems to not like:
// Auto Role
client.on('guildMemberAdd", member => {
console.log("User " + member.user.tag + " has joined the server!");
var role = member.guild.roles.cache.find("name", "User");
member.addRole(role);
});
You're using an old version of Collection.find(): in its current version the "property-value" way of using .find is no longer supported, you need to provide a function. You can find the docs here.
Here's how you can code it:
client.on('guildMemberAdd', member => {
let role = member.guild.roles.cache.find(r => r.name == 'User')
member.roles.add(role)
})
Also, as you may have noticed, you also need to write member.roles.add, since GuildMember.addRole() is a method from v11.

using LessCss in asset_compress plugin with CakePHP4

I fail to set up LessCss filter with asset_compress plugin on a new CakePHP4 app.
Read the docs: https://github.com/markstory/asset_compress/wiki
There are some examples on js filters and config in general, so I set up mine like so:
[General]
cacheConfig = false
[js]
cachePath = WEBROOT/cache_js/
[css]
cachePath = WEBROOT/cache_css/
[less]
filters[] = LessCss
[app-v1.css]
files[] = WEBROOT/less/app-v1.less
What happens is app-v1.less get parsed like a css file, so all the Less stuff is still there and not processed properly.
When adding filters[] = LessCss to [css] or [app-v1.css] get an error:
Error: /usr/local/lib/node_modules/less/dist/less.cjs.js:6735
imports.contents[fileInfo.filename] = str;
^
TypeError: Cannot read property 'contents' of undefined
at Object.parse (/usr/local/lib/node_modules/less/dist/less.cjs.js:6735:20)
at Object.<anonymous> (/Users/yy/www/fudis_app/tmp/asset_compress_less6IDAL9:5:8)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
I understand this is a general question and possibly I am missing something in the docs or general understanding, but a simple example of a proper config would be really handy. Thanks!

Meteor/React: Your app is crashing but fixed error?

I keep getting this error below but when I update the Resolutions.graphql file to correct the typo, I still get the error.
Tried restarting the Meteor server but still receiving the error.
Anything I'm missing?
Error: Unknown type "Sting". Did you mean "String"?
at assertValidSDL (/Users/macos/apollo/node_modules/graphql/validation/validate.js:89:11)
at Object.buildASTSchema (/Users/macos/apollo/node_modules/graphql/utilities/buildASTSchema.js:76:34)
at Object.buildSchemaFromTypeDefinitions (/Users/macos/apollo/node_modules/graphql-tools/dist/generate/buildSchemaFromTypeDefinitions.js:23:28)
at makeExecutableSchema (/Users/macos/apollo/node_modules/graphql-tools/dist/makeExecutableSchema.js:26:29)
at register-api.js (imports/startup/server/register-api.js:22:16)
at fileEvaluate (packages/modules-runtime.js:336:7)
at Module.require (packages/modules-runtime.js:238:14)
at Module.moduleLink [as link] (/Users/macos/.meteor/packages/modules/.0.13.0.1pfv79d.ujmak++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/reify/lib/runtime/index.js:38:38)
at index.js (imports/startup/server/index.js:1:8)
at fileEvaluate (packages/modules-runtime.js:336:7)
at Module.require (packages/modules-runtime.js:238:14)
at Module.moduleLink [as link] (/Users/macos/.meteor/packages/modules/.0.13.0.1pfv79d.ujmak++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/reify/lib/runtime/index.js:38:38)
at init.js (server/init.js:1:8)
at fileEvaluate (packages/modules-runtime.js:336:7)
at Module.require (packages/modules-runtime.js:238:14)
at require (packages/modules-runtime.js:258:21)
Exited with code: 1
Your application is crashing. Waiting for file change.
Resolutions.graphql:
type Resolutions {
_id: String!
name: String!
}
Finally got it to work using meteor reset instead of just cmd + c and then meteor

Resources