I'm trying to make my bot send embededmessages and each time I send the message it gives me an error like this "cannot read property 'send' of undenified".Here is my code
else if(message.content == "testing") {
let channel = message.guild.channels.cache.get(832075875612491789)
const exampleEmbed = new MessageEmbed()
.setColor('#0099ff')
.setTitle('v1.1 test')
.setThumbnail('https://i0.wp.com/www.mysabah.com/wordpress/wp-content/uploads/2006/06/252.jpg?fit=640,392&ssl=1')
channel.send({ embeds: [exampleEmbed] });
}
CodePudding user response:
Your channel isn't defined, presumably because you're using an integer to get it instead of a string.
Snowflakes in Discord are stored as string, so instead of fetching the channel using a number, use the following:
let channel = message.guild.channels.cache.get("832075875612491789");
CodePudding user response:
else if(message.content == "testing") {
let channel = message.guild.channels.cache.get("832075875612491789")
const exampleEmbed = new MessageEmbed()
.setColor('#0099ff')
.setTitle('v1.1 test')
.setThumbnail('https://i0.wp.com/www.mysabah.com/wordpress/wp-content/uploads/2006/06/252.jpg?fit=640,392&ssl=1')
channel && channel.send({ embeds: [exampleEmbed] });
}