TypeError:无法读取null的属性“ then” discord.js

时间:2020-09-24 19:50:15

标签: node.js discord discord.js

我正在尝试创建消息跟踪器,并且显示此错误,我不知道为什么

代码:messagecounter.js

const db = require('quick.db');

module.exports = {
    name: "msgc",
    description: "Message Counter",

    async run(client, message, args) {

        // checking who wants to fetch it
        let member = message.mentions.members.first() || message.member; // this checks if they mentioned a members

        db.fetch(`messageSent_${member.id}`).then(obj => {

            message.channel.send(`**Messages Sent:** \`${obj.value}\``);

        });
    }

}

代码:bot.js:70:42

client.commands.get(command).run(client, message, args);

错误:

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'then' of null
    at Object.run (C:\Users\Familia\OneDrive\Documents\Other Stuff\Visual Studio code\blade\commands\messagecounter.js:13:45)
    at Client.<anonymous> (C:\Users\Familia\OneDrive\Documents\Other Stuff\Visual Studio code\blade\bot.js:70:42)

任何帮助将不胜感激

使用discord.js v12

1 个答案:

答案 0 :(得分:1)

快速浏览“ quick.db”后,我找不到在db对象上定义的名为fetch的方法。但是,“获取”已定义,也许就是您打算使用的内容。