I have an error that I cannot solve.
So I have a warn.js file that has an error. The file is https://sourceb.in/6Hrc2IpLUt and the error is: TypeError: Cannot read properties of null (reading 'id')
at Object.execute (D:\Happybottesttobeofficial\slashcommands\warn.js:26:89)
at Client.<anonymous> (D:\Happybottesttobeofficial\index.js:52:19)
at Client.emit (node:events:520:28)
at InteractionCreateAction.handle (D:\Happybottesttobeofficial\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (D:\Happybottesttobeofficial\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (D:\Happybottesttobeofficial\node_modules\discord.js\src\client\websocket\WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (D:\Happybottesttobeofficial\node_modules\discord.js\src\client\websocket\WebSocketManager.js:232:12)
at WebSocketManager.emit (D:\Happybottesttobeofficial\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
at WebSocketShard.<anonymous> (D:\Happybottesttobeofficial\node_modules@discordjs\ws\dist\index.js:1190:51)
at WebSocketShard.emit (D:\Happybottesttobeofficial\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
27 Replies
- 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!
- ✅
Marked as resolved by OPSeems like member is null
Which mean no member was passed in or they arent in the guild
or interaction.guild is null, meaning its a dm command, a user app, or you dont have the Guilds intent
I have a test server with 10 bots and 3 including me real person.
I think I have the guild intent but let me check
Does these intents enough to have? GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent
And if you want to know thats my index.js https://sourceb.in/ZEaHFCYtto
And the prefix command that is the same js not slashcommandbuilder is working. https://sourceb.in/Wde3wYOhst
Then this
Log to confirm
What does member is null mean?
And I now tried to do with a bot that has 0 permission.
Like the permission code is 0
And the same error appeared.
The member isnt in the server
But as long as you dont log it to make sure, i cant help you
The member is on the server I am trying to warn
plus thats the code thats prefix and it works
What do you mean log it?
Console log it
Like show the console?
do you not know how to use console.log?
I do sir.
Then do so
And log member
Just that.
Alright.
One sec lemme try.
Ah
Got the problem
Executing warn command
Member object: null
Reason: rew
Member not found
That's the console.log
So
The member isn't even a member
So can the problem be solved if I warn a normal member.
?
yes
Alright. And does bots with 0 permission count?
anyone that is a member of the server
And not a bot right?
Alright.
Thanks for helping.
But another question.
Bots are also members
This command doesn't work either. https://sourceb.in/WAkpD6k6XZ
I assume it has the same problem.
Do they have to be online?
No
Doesnt work in what way? If its the same error then yes
Then, I have a bot not online and it says this in the console. Executing warn command
Member object: null
Reason: 1
Member not found
Yeah it is the same error.
But even when I console.log it
It says this to a bot that isnt online
Executing warn command
Member object: null
Reason: 1
Member not found
and has 0 permission.
Then the bot isnt in the server (or does not have the bot scope)
Oh alright.
You dont leave a server when you go offline
Thanks for your help.
So neither do bots
But the bot is on the server.
nvm
have a nice day
bye