Properties of undefined „send"

Hello, following code
const { Events, EmbedBuilder } = require('discord.js');
const path = require('node:path');

require('dotenv').config({
path: path.join(__dirname, '.env'),
})

const channelLogChannel = process.env.CHANNEL_LOG_CHANNEL
const botEmbedFooterText = process.env.BOT_EMBED_FOOTER_TEXT

module.exports = {
name: Events.ChannelUpdate,
once: false,
execute(oldChannel, newChannel) {
const toChannel = oldChannel.client.channels.cache.get(channelLogChannel)
const oldChannelName = oldChannel.name
const newChannelName = newChannel.name
const embed = new EmbedBuilder()
.setTitle('A channel has changed')
.setDescription('This message is a notice and was created automatically')
.addFields(
{ name: 'Old channel name', value: oldChannelName },
{ name: 'New channel name', value: newChannelName },
)
.setFooter({ text: botEmbedFooterText, iconURL: oldChannel.client.user.displayAvatarURL() });
toChannel.send({ embeds: [embed] })
}
};
const { Events, EmbedBuilder } = require('discord.js');
const path = require('node:path');

require('dotenv').config({
path: path.join(__dirname, '.env'),
})

const channelLogChannel = process.env.CHANNEL_LOG_CHANNEL
const botEmbedFooterText = process.env.BOT_EMBED_FOOTER_TEXT

module.exports = {
name: Events.ChannelUpdate,
once: false,
execute(oldChannel, newChannel) {
const toChannel = oldChannel.client.channels.cache.get(channelLogChannel)
const oldChannelName = oldChannel.name
const newChannelName = newChannel.name
const embed = new EmbedBuilder()
.setTitle('A channel has changed')
.setDescription('This message is a notice and was created automatically')
.addFields(
{ name: 'Old channel name', value: oldChannelName },
{ name: 'New channel name', value: newChannelName },
)
.setFooter({ text: botEmbedFooterText, iconURL: oldChannel.client.user.displayAvatarURL() });
toChannel.send({ embeds: [embed] })
}
};
Produces an error. I think is an markdown error or?
No description
7 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
h4ze
h4zeOP7mo ago
My English is not that good but I am grateful for any help.
chewie
chewie7mo ago
Can you log and show whats in channelLogChannel
h4ze
h4zeOP7mo ago
Ok you mean the variable is not defined in env? .. thank you .. can you say me who I can get the creator from channelCreate event?
d.js docs
d.js docs7mo ago
:guide: Popular Topics: Working with Audit Logs read more
h4ze
h4zeOP7mo ago
I don’t understand this for my code. Can you explain me an example?
chewie
chewie7mo ago
The guide I linked you already gives you plenty of examples.
Want results from more Discord servers?
Add your server