我一直在制造一个不和谐的机器人,我不知道当前的问题是什么,请帮忙。
module.exports = {
name: "blah",
category: "blahblah",
description: "blahblah",
run: async (client, message, args) => {
const Discord = require('discord.js');
let numMessages = args[0];
let fetched = await message.channel.messages.fetch({limit: numMessages});
console.log(arr = fetched.array());
for(let i = 0; i < arr.length; i++){
const RichEmbed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('blahblah')
.setAuthor(message.author.tag)
.addField('blahblah', message.author.tag)
.addField('blahblah', message.content)
.client.channels.cache.get("692783192574263364").send(RichEmbed);
}
message.channels.bulkDelete(args[0]);
}
它告诉我下一行:
(node:7736) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'channels' of undefined
at Object.run C:\PathToMyBotFolder\ThisScript:17:20)`
答案 0 :(得分:0)
由于代码中有错字,您写了.client
而不是client
将.client.channels.cache.get("692783192574263364").send(RichEmbed);
替换为client.channels.cache.get("692783192574263364").send(RichEmbed);