reading guilds TypeError

Hey,
const { Events } = require('discord.js');

module.exports = {
name: Events.ChannelUpdate,
once: false,
execute(oldChannel, newChannel, client) {
console.log(`${client.guilds.cache.size}`);
console.log(`channelUpdate: ${oldChannel.name} | ${newChannel.name}`);
}
};
const { Events } = require('discord.js');

module.exports = {
name: Events.ChannelUpdate,
once: false,
execute(oldChannel, newChannel, client) {
console.log(`${client.guilds.cache.size}`);
console.log(`channelUpdate: ${oldChannel.name} | ${newChannel.name}`);
}
};
show me an error. Can you pls help me?
No description
14 Replies
d.js toolkit
d.js toolkit7mo 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! - Marked as resolved by OP
TÆMBØ
TÆMBØ7mo ago
You're likely not passing your client into your execute() function for your event handler, nor do you really need to since just about all d.js structures have a client property
h4ze
h4zeOP7mo ago
Then why doesn't it work? I don't understand the problem
TÆMBØ
TÆMBØ7mo ago
My first sentence explains why your code is not functioning
h4ze
h4zeOP7mo ago
So I don't need to pass 'client'? Because all DJs have one? That's what I read.
TÆMBØ
TÆMBØ7mo ago
Correct, just use oldChannel.client Or newChannel, doesn't matter since both are channel instances that have it
h4ze
h4zeOP7mo ago
ok and how do I access a channel within the event so that I can send a message?
TÆMBØ
TÆMBØ7mo ago
Assuming you have the Guilds intent, <Client>.channels.cache.get(channelId) to get the channel you want
d.js docs
d.js docs7mo ago
:method: TextBasedChannel#send() Sends a message to this channel.
h4ze
h4zeOP7mo ago
I'm asking because the original goal was to send a message in a channel when someone creates a new channel. However, I was never able to access the channel list. So I wanted to work on it bit by bit. And with oldchannel before?
TÆMBØ
TÆMBØ7mo ago
To get to the Client, yes
h4ze
h4zeOP7mo ago
aaaaaaaah .. I understand .. pretty easy ..
d.js docs
d.js docs7mo ago
:property: GuildChannel#client The client that instantiated this
h4ze
h4zeOP7mo ago
Thank you so Mitch Mutch
Want results from more Discord servers?
Add your server