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 toolkit17mo 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!
AeroBytes
AeroBytesOP17mo ago
[email protected] - Node.js v18.16.0
chewie
chewie17mo ago
client.login() not Client.login()
AeroBytes
AeroBytesOP17mo 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
chewie17mo ago
I somehow very much doubt that did you save your code and restart
AeroBytes
AeroBytesOP17mo ago
I did save my code and rebooted VScode He does see it still as Client.login
AeroBytes
AeroBytesOP17mo ago
chewie
chewie17mo ago
Then you did, in fact, not save
AeroBytes
AeroBytesOP17mo ago
I pressed save
chewie
chewie17mo ago
but I sure wonder why you are in the node_modules\discord.js\src folder
AeroBytes
AeroBytesOP17mo 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
chewie17mo ago
I know its saturday, but please no snailing here
AeroBytes
AeroBytesOP17mo ago
Im familair with PHP / Python structures, totaly not with JS
chewie
chewie17mo ago
the main bot file can be anywhere in the bot folder, just not in the node_modules folder
AeroBytes
AeroBytesOP17mo ago
Ahh clear!
Want results from more Discord servers?
Add your server