discord.js-无法读取未定义的属性“通道”

时间:2020-04-08 16:29:48

标签: discord discord.js

我一直在制造一个不和谐的机器人,我不知道当前的问题是什么,请帮忙。

    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)`

1 个答案:

答案 0 :(得分:0)

由于代码中有错字,您写了.client而不是client

.client.channels.cache.get("692783192574263364").send(RichEmbed);替换为client.channels.cache.get("692783192574263364").send(RichEmbed);