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
d.js toolkit
d.js toolkit•10mo 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!
KelvinCodes
KelvinCodes•10mo ago
discord.js@14.12.1 - Node.js v18.16.0
chewie 🌈
chewie 🌈•10mo ago
client.login() not Client.login()
KelvinCodes
KelvinCodes•10mo ago
Ohw, now i get client.login is not a function Code i use:
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('tokenIdidHere')
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('tokenIdidHere')
chewie 🌈
chewie 🌈•10mo ago
I somehow very much doubt that did you save your code and restart
KelvinCodes
KelvinCodes•10mo ago
I did save my code and rebooted VScode He does see it still as Client.login
KelvinCodes
KelvinCodes•10mo ago
chewie 🌈
chewie 🌈•10mo ago
Then you did, in fact, not save
KelvinCodes
KelvinCodes•10mo ago
I pressed save
chewie 🌈
chewie 🌈•10mo ago
but I sure wonder why you are in the node_modules\discord.js\src folder
KelvinCodes
KelvinCodes•10mo ago
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
chewie 🌈
chewie 🌈•10mo ago
I know its saturday, but please no snailing here
KelvinCodes
KelvinCodes•10mo ago
Im familair with PHP / Python structures, totaly not with JS
chewie 🌈
chewie 🌈•10mo ago
the main bot file can be anywhere in the bot folder, just not in the node_modules folder
KelvinCodes
KelvinCodes•10mo ago
Ahh clear!