【问题标题】:TypeError: Cannot read property 'then' of null | discord.jsTypeError:无法读取 null 的属性 'then' |不和谐.js
【发布时间】:2021-01-11 03:50:23
【问题描述】:

我正在尝试制作消息跟踪器,但显示此错误,我不知道为什么

代码: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

【问题讨论】:

    标签: node.js discord discord.js


    【解决方案1】:

    快速浏览“quick.db”后,我找不到在 db 对象上定义的名为 fetch 的方法。但是,“get”是已定义的,并且可能是您打算使用的。

    【讨论】:

    • 根据 quick.db 的文档,没有一个方法返回 Promise。 get 方法返回一个对象,在您的情况下该对象为空。这可能意味着被查询的对象不存在。
    • 这里是文档的链接:quickdb.js.org/overview/docs
    猜你喜欢
    • 2021-04-14
    • 2021-05-18
    • 2023-03-30
    • 1970-01-01
    • 2020-11-10
    • 2020-11-11
    • 2021-04-15
    • 2021-05-10
    • 1970-01-01
    相关资源
    最近更新 更多