Cannot read properties of undefined (reading 'Client')
Hi, so i need to add intents to my basic bot. Now it cant read
Client
anymore when i do this, does anyone sees where it goes wrong?
``ts
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});
client.on("ready", () => {
console.log(
Logged in as ${client.user.tag}!`)
})
client.on("message", msg => {
if (msg.content === "ping") {
msg.reply("pong");
}
})
Client.login('tokenHere')15 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!client.login() not Client.login()
Ohw, now i get client.login is not a function
Code i use:
I somehow very much doubt that
did you save your code and restart
I did save my code and rebooted VScode
He does see it still as
Client.login
Then you did, in fact, not save
I pressed save
but I sure wonder why you are in the node_modules\discord.js\src folder
Control + S inside the file i did to, and restarted VScode
Now i wonder it to
I try different directory
Is works now, howkey, weurd
I saw a tutorial, touch it needed in the
src
I know its saturday, but please no snailing here
Im familair with PHP / Python structures, totaly not with JS
the main bot file can be anywhere in the bot folder, just not in the node_modules folder
Ahh clear!