다른 서버로 메시지를 보내는 명령을 사용할 때 "TypeError : Cannot read property 'cache'of undefined"오류가 발생합니다.
fsn.readJSON("././orders.json").then((orderDB) => {
let ticketID = args[0];
let order = orderDB[ticketID];
// If the order doesn't exist.
if(order === undefined) {
message.reply(`Couldn't find order \`${args[0]}\` Try again.`);
return;
}
if(!args[0]) {
message.reply('Correct usage: \`.deliver (order ID)\` Remember to have an attachment while using the command.');
return;
}
if (message.author.id === order.chef) {
if (order.status === "Ready") {
if (message.attachments.size > 0) {
message.attachments.forEach(Attachment => {
message.channels.cache.get(order.channelID).send(`Hi <@${order.userID}> I'm <@${order.chef}> and here is your taco that you ordered. Remember you can use \`.feedback [Feedback]\` to give us feedback on how we did. ${Attachment.url}`);
})
} else {
return message.reply('Please attach an attachment while using the command.');
}
delete orderDB[ticketID];
fsn.writeJSON("./orders.json", orderDB, {
replacer: null,
spaces: 4
}).then(() => {
message.reply(`Order \`${args[0]}\` Has been sent.`)
console.log(`Order ${args[0]} has been delivered by ${order.chefmention}`)
}).catch((err) => {
if (err) {
message.reply(`There was an error while writing to the database! Show the following message to a developer: \`\`\`${err}\`\`\``);
}
});
} else {
message.reply("This order hasn't been claimed yet. Run `.claim [Order ID]` to claim it.");
}
} else {
message.channel.send(`Only the chef of the order ${order.chefmention} may deliver this order`);
}
})
오류가 message.channels.cache.get(order.channelID).send(`Hi <@${order.userID}> I'm <@${order.chef}> and here is your taco that you ordered. Remember you can use \`.feedback [Feedback]\` to give us feedback on how we did. ${Attachment.url}`);
"order.channel.ID"에있는 것 같습니다. orders.json 파일에 저장되어 있고 코드에 어떤 문제가 있는지 모르겠습니다.
Message
객체에 channels
속성 이 없습니다. 아마도 다음을 사용하려고했을 것입니다.
message.client.channels.cache.get() //...
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다