我在使用嵌入式消息时一直收到错误消息,因为 "cannot read property 'send' of undenifide"
I'm having keep getting and error while using embeded messages because "cannot read property 'send' of undenifide"
我试图让我的机器人发送嵌入的消息,每次我发送消息时它都会给我这样的错误“无法读取 属性 'send' of undenified”。这是我的代码
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%2C392&ssl=1')
channel.send({ embeds: [exampleEmbed] });
}
您的频道未定义,可能是因为您使用整数而不是字符串来获取它。
Discord 中的雪花存储为字符串,因此不要使用数字获取频道,而是使用以下内容:
let channel = message.guild.channels.cache.get("832075875612491789");
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%2C392&ssl=1')
channel && channel.send({ embeds: [exampleEmbed] });
}
要在特定频道中发送消息,或通过 ID 调用频道,以存储我们需要字符串的频道 ID,请使用此
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%2C392&ssl=1')
channel.send({ embeds: [exampleEmbed] });
}
一切都很好,但你应该在行中进行更改
let channel = message.guild.channels.cache.get("832075875612491789")
我试图让我的机器人发送嵌入的消息,每次我发送消息时它都会给我这样的错误“无法读取 属性 'send' of undenified”。这是我的代码
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%2C392&ssl=1')
channel.send({ embeds: [exampleEmbed] });
}
您的频道未定义,可能是因为您使用整数而不是字符串来获取它。
Discord 中的雪花存储为字符串,因此不要使用数字获取频道,而是使用以下内容:
let channel = message.guild.channels.cache.get("832075875612491789");
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%2C392&ssl=1')
channel && channel.send({ embeds: [exampleEmbed] });
}
要在特定频道中发送消息,或通过 ID 调用频道,以存储我们需要字符串的频道 ID,请使用此
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%2C392&ssl=1')
channel.send({ embeds: [exampleEmbed] });
}
一切都很好,但你应该在行中进行更改
let channel = message.guild.channels.cache.get("832075875612491789")