类型错误:无法读取未定义的属性“logsChannel”

时间:2021-07-25 06:26:32

标签: node.js mongodb mongoose discord eris

不久前我从 rethinkdb 切换到 mongoose,当然我已经重新编码了大部分内容。我不断收到垃圾邮件TypeError: Cannot read property 'logsChannel' of undefined at Trinity.exports.handle (/home/ubuntu/Trinity/src/events/guildMemberAdd.js:5:22)

它经常发送垃圾邮件,而且我的其他活动也会出错。

const Guild  = require('../db/models/Guild');

exports.handle = async function (guild, member) {   
    let logs = await Guild.findOne({ guildID: guild.id })
    if(logs.lchannel.logsChannel.enabled == false) return;
    this.bot.createMessage(logs.lchannel.logsChannel.channelID, {
        embed: {
            author: {
                name: `${member.username}#${member.discriminator}`,
                icon_url: member.avatarURL
            },
            color: 0x2196F3,
            timestamp: new Date(),
            fields: [
                {
                    name: "Member Joined",
                    value: `**${member.username}** has joined **${guild.name}**`
                }
            ]
        }
    }).catch(err => { });


that is my code.

0 个答案:

没有答案