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