【发布时间】:2020-11-12 14:59:03
【问题描述】:
当我尝试为 discord bot 创建 StateManager.js 文件时出现错误,当我尝试启动 discord bot 时出现错误 .then((connection) => this.connection = 连接) ^ TypeError: connection.then 不是函数,有什么解决办法吗?该连接是使用单独的文件连接到一个不和谐机器人的数据库,而不是在 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();
【问题讨论】:
标签: javascript discord discord.js