发送未定义 [英] send is not defined
本文介绍了发送未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道如何修复TypeError Cannot read property 'send' of undefined
这是由我获得频道702825446248808519
I don't get how to fix the TypeError Cannot read property 'send' of undefined
This is caused by the line where I get the channel 702825446248808519
module.exports = {
name: 'suggest',
aliases: ['sug', 'suggestion'],
description: 'Suggest something for the Bot',
execute(client, message) {
const filter = m => m.author.id === message.author.id;
message.channel.send(`Please provide a suggestion for the Bot or cancel this command with "cancel"!`)
message.channel.awaitMessages(filter, { max: 1, })
.then(async (collected) => {
if (collected.first().content.toLowerCase() === 'cancel') {
message.reply("Your suggestion has been cancelled.")
}
else {
const embed = new RichEmbed()
.setFooter(client.user.username, client.user.displayAvatarURL)
.setTimestamp()
.addField(`New Suggestion from:`, `**${message.author.tag}**`)
.addField(`Suggestion:`, `${collected.first().content}\n**Its your choice!**`)
.setColor('0x0099ff');
client.channels.get("702825446248808519").send(embed)
message.channel.send(`Your suggestion has been filled to the staff team. Thank you!`)
}
})
},
catch(err) {
console.log(err)
}
};
推荐答案
.get()
不是 ChannelManager
,则需要使用因此您的行client.channels.get("702825446248808519").send(embed)
需要替换为client.channels.fetch("702825446248808519").send(embed)
So your line client.channels.get("702825446248808519").send(embed)
needs to be replaced with client.channels.fetch("702825446248808519").send(embed)
这篇关于发送未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文