无法读取未定义SQLite的属性

时间:2018-07-11 11:15:27

标签: node.js sqlite undefined discord.js

我以前在SQLite上遇到过一些问题,现在又遇到了一个问题。我的问题是:

    (node:24344) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'elite' of undefined
(node:24344) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate
the Node.js process with a non-zero exit code.
(node:24344) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot set property 'money' of undefined
(node:24344) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: Cannot read property 'toLowerCase' of undefined
(node:24344) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): TypeError: Cannot set property 'money' of undefined

我已经尝试调试一些东西,但是找不到未定义的内容,我尝试将client.farm.money = row.money更改为client.farm.money = row.level以查看问题是否存在,但是仍然是不确定的,这是我正在使用的代码:

client.sql.get(`SELECT * FROM farm WHERE userid = "${message.author.id}"`).then(row => {
        if(!row) {
            return message.channel.send('I\'m sorry but something went wrong try again or contact a bot administrator!')
        } else {
        client.farm.money = row.money
        client.farm.level = row.level
        client.farm.xp = row.xp
        client.farm.chickens = row.chickens
        client.farm.farmers = row.farmers
        client.farm.delivery = row.delivery
        client.farm.wizard = row.wizard
        client.farm.omega = row.omega
        client.farm.goldchick = row.goldchick
        client.farm.robot = row.robot
        client.farm.cegg = row.cegg
        client.farm.ucegg = row.ucegg
        client.farm.regg = row.regg
        client.farm.eegg = row.eegg
        client.farm.legg = row.legg
        client.farm.megg = row.megg
        client.farm.elite = row.legg
        client.farm.daily = row.daily
        client.farm.collected = row.collected
        client.farm.car = row.car
        client.farm.house = row.house
        client.farm.farm = row.farm
        } 
    })
    if(!args[0]) {
        let embed = new Discord.RichEmbed()
        .setTitle('Farm Usage')
        .setDescription(`${prefix}farm inv | *Open your farm inventory*\n${prefix}farm reward | *Collecy your daily, vote or an event reward*\n${prefix}farm buy | *Buy chickens, farmers and delivery persons*\n${prefix}farm upgrade | *Upgrade your house, farm or car*\n${prefix}farm collect | *Collect the money you have in your safe*\n${prefix}farm rob | *Coming soon!*\n${prefix}eggs buy/open | *Open or buy eggs for special rewards!*`)
        .setColor('#36393E')
        .setFooter(`Requested by ${message.author.tag}`, message.author.avatarURL)
        message.channel.send(embed)
    }
    if(args[0].toLowerCase() === 'inv') {
        let u;
        if(client.farm.elite === 'false') u = `${message.author.tag}`
        if(client.farm.elite === 'true') u = `<:ELITE3:461916799944884246> ${message.author.tag}`

        let fmoney = parseInt(client.farm.chickens) / 2;
        let money2 = parseInt(client.farm.delivery) + 1;
        let money3 = money2 * fmoney;
        let money4 = money3 * parseInt(client.farm.farmers) + 1;
        if(parseInt(client.farm.chickens) === 0) money4 = 0;
        if(parseInt(client.farm.farmers) === 0) money4 = 0;
        if(isNaN(money4)) return message.channel.send('I\'m sorry but something went wrong try again or contact a bot administrator!')

        let elitedubbel;
        if(client.farm.elite === 'false') elitedubbel = 1;
        if(client.farm.elite === 'true') elitedubbel = 2;

        let show$ = money4 * elitedubbel;
        let showmoney = parseInt(client.farm.money)

        let wizard = client.farm.wizard
        let robot = client.farm.robot
        let omega = client.farm.omega
        let gold = client.farm.goldchick

        let wait1 = (Date.now() - cliet.farm.collected);
        let wait2 = wait1 / 3600000;
        let timeLeft = Math.round(wait2)
        if(wait2 < 1) timeLeft = 0;
        let maxuur;
        if(wizard === '❓') maxuur = 48;
        if(wizard === '<:wizardchick:464077946643152907>') maxuur = 96;

        let c = client.farm.cegg
        let uc = client.farm.ucegg
        let r = client.farm.regg
        let e = client.farm.eegg
        let l = client.farm.legg
        let m = client.farm.megg

        let nodigxp = client.farm.level * 200
        let tilllevel = nodigxp - parseInt(client.farm.xp)

        let embed = new Discord.RichEmbed()
        .setTitle(`${u}'s farm`)
        .addField(`Information`, `Income <:dollarbill:461905158624772096>${show$.toLocaleString('en')}/hour\nWaited ${timeLeft}/${maxuur} hours\nProducing ${Math.round(parseInt(money4) / 3).toLocaleString('en')} Eggs\nWorth about <:dollarbill:461905158624772096>${3 * elitedubbel}/egg\nMoney <:dollarbill:461905158624772096>${showmoney.toLocaleString('en')}`)
        message.channel.send(embed)
    }

0 个答案:

没有答案