使用我的命令向另一台服务器发送消息时出现错误“TypeError:无法读取未定义的属性'缓存'”
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 文件中并被定义,我不知道代码有什么问题
答案 0 :(得分:0)
Message
对象没有 channels
属性,您可能打算使用:
message.client.channels.cache.get() //...