Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 与基座的连接未关闭_Javascript_Node.js_Discord.js_Mysql2 - Fatal编程技术网

Javascript 与基座的连接未关闭

Javascript 与基座的连接未关闭,javascript,node.js,discord.js,mysql2,Javascript,Node.js,Discord.js,Mysql2,我正在使用mysql2处理数据库。 当处理从消息中移除反应的触发器时,连接未关闭,它传递.end()命令,但不执行任何操作 const mysql = require('mysql2'); const mysql_cfg = require('../mysql_cfg.json'); module.exports.run = async (messageReaction, user) => { try { var con = mysql.createPool(mysql_

我正在使用mysql2处理数据库。 当处理从消息中移除反应的触发器时,连接未关闭,它传递
.end()
命令,但不执行任何操作

const mysql = require('mysql2');
const mysql_cfg = require('../mysql_cfg.json');

module.exports.run = async (messageReaction, user) => {

  try {

    var con = mysql.createPool(mysql_cfg).promise();

  if (user.bot != true) {

    if (messageReaction._emoji.id === '812934232799969361' && messageReaction.message.author.id === '789484089736429589' && messageReaction.message.embeds[0].author.name === 'Destiny 2') {   
      
      if (messageReaction.message.embeds[0].fields[0].value.search(user.id) >= 0) { 
        
      } else {

      let a = messageReaction.users.cache.filter(val => val.bot === false)
      let b = a.map(v => v.id)
      let sbor_notification = ""

      await con.execute(`UPDATE events SET users = '${b}', json_users = '${sbor_notification}' WHERE id = '${messageReaction.message.id}'`);

    messageReaction.message.edit("@here"); 
    } 
    }
  }
con.end();
} catch (error) {
  console.error(error);
}
};

你好欢迎来到stackoverflow!我建议你看看这篇关于如何提出好问题的文章:另外,我建议你使用准备好的语句或类似的方法来构建sql查询,因为构建sql查询的方式容易受到sql注入攻击:最后,不管发生什么情况,都要关闭db连接,您是否检查了
try…catch
finally
语句?