good day
尝试向数据库添加数据时抛出错误UnhandledPromiseRejectionWarning: Error: Pool is closed
需要将消息 id 上传到数据库
如果有其他方法可以按顺序发送 mysql 查询,我准备考虑,但目前我喜欢这种方法比较多,我只需要了解问题的原因并找到解决方法
const mysql = require("mysql2");
const mysql_cfg = require("../mysql_cfg.json");
module.exports = {
name: "test",
execute(message, args) {
let lider_id = message.author.id;
var con = mysql.createPool(mysql_cfg).promise();
message.delete();
con
.execute(`SELECT id, date_unblock FROM blocks WHERE id = "${lider_id}"`)
.then((result) => {
message.channel.send("test").then((msg) => {
setTimeout(function () {
msg.edit("@here").then(function (message) {
message.react("+");
});
}, 1000);
return con.execute(`INSERT INTO events (id) VALUES ("${msg.id}")`);
});
})
.then(() => {
con.end();
})
.catch((err) => {
console.log(err);
});
},
};