【发布时间】:2020-04-08 16:29:48
【问题描述】:
我一直在制作一个不和谐的机器人,但我不知道当前的问题是什么,请帮忙。
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)`
【问题讨论】:
-
欢迎来到 Stack Overflow。作为 SO 社区服务的一部分,我冒昧地编辑了您的帖子,因此它更简洁,可以更好地帮助他人。看看stackoverflow.com/posts/61105476/revisions - 也许这会给你一些提示,如何改进 SO 的格式和简洁性。
-
关于您最初的问题:您是否注意到错误消息的结尾为
:17:20)?这是运行时的提示,它在第 17 行、第 20 字符处发生故障。也许这有帮助。
标签: discord discord.js