How has this line changed from v13?
const testGuild = client.guilds.cache.get('1006932090102747238');
It is saying TypeError: Cannot read properties of undefined (reading 'guilds')
23 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.14.2.0 & 16.15.0
client is undefined
(It has not changed)
Alright, any ideas why that is @mozzy ? now that you say that I do see another error on the console.log here:
guildCreate only emits
guild
. You will need to pass client another way. Or you can probably do guild.client
Doesn't work. So how do people get bots to send messages when they first get added to a guild?
guild.channels
is a thing
And some additional channel properties https://discord.js.org/#/docs/discord.js/stable/class/GuildDiscord.js
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Where are you trying to send the message?
In a test server using the variable
testGuild
in a specific channel that only I can see.And why can't you use guild.client.guilds.cache.get()?
This is why
Read my message again
line 11 is the last line here:
Don't I still need to get the ID that the channel is in?
Well,
client
isn't defined guild.client
probably isOkay, now it is saying
channels
isn't defined... entire command:
this line is causing it... channel = testGuild.channels.cache.get('1006932090102747238');
Valid guildId?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Alright will do. Ty!
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
It doesn’t need it for time stamp
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Nope
But why use it?