Javascript 连接。那么它不是一个函数

Javascript 连接。那么它不是一个函数,javascript,discord,discord.js,Javascript,Discord,Discord.js,当我尝试为discord bot创建StateManager.js文件时,我遇到了一个错误,当我尝试启动discord bot时,我得到了一个错误。然后((connection)=>this.connection=connection) ^ TypeError:connection.then不是一个函数,是否对此进行了修复?连接是使用单独的文件连接到discord bot的数据库,而不是在index.js文件中 const { EventEmitter } = require('events')

当我尝试为discord bot创建StateManager.js文件时,我遇到了一个错误,当我尝试启动discord bot时,我得到了一个错误。然后((connection)=>this.connection=connection) ^ TypeError:connection.then不是一个函数,是否对此进行了修复?连接是使用单独的文件连接到discord bot的数据库,而不是在index.js文件中

const { EventEmitter } = require('events');
const connection = require('../../database/db');

class StateManager extends EventEmitter{
    constructor (opts){
        super(opts);
        connection
        .then((connection) => this.connection = connection)
            .catch(err => console.log(err));
        



    }
}

module.exports = new StateManager();
假设“connection”应该返回一个承诺,您首先必须调用connection方法来访问该承诺

class StateManager扩展了EventEmitter{
建造师(opts){
超级(opts);
连接()
.然后((连接)=>this.connection=连接)
.catch(err=>console.log(err));
}
}