Database coded with Djs

I coded my mySQL database with discord.js. After a certain time limit (unsure how long) the connection times out and I'm unsure what to do about it. If anyone can help I appreciate it. Code:
require('dotenv').config();
const mysql = require('mysql2/promise');

module.exports = mysql.createConnection({
host: 'localhost',
user: 'sam',
password: 'Virginia107',
database: 'RVABot',
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
maxIdle: 0, // Disable maxIdle - connections stay in the pool even if idle
idleTimeout: 60000, // Close idle connections after 60 seconds (should be much less than MySQL's wait_timeout)
enableKeepAlive: true // Enable TCP keep-alive packets
});
require('dotenv').config();
const mysql = require('mysql2/promise');

module.exports = mysql.createConnection({
host: 'localhost',
user: 'sam',
password: 'Virginia107',
database: 'RVABot',
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
maxIdle: 0, // Disable maxIdle - connections stay in the pool even if idle
idleTimeout: 60000, // Close idle connections after 60 seconds (should be much less than MySQL's wait_timeout)
enableKeepAlive: true // Enable TCP keep-alive packets
});
Error:
Error: Can't add new command when connection is in closed state
Error: Can't add new command when connection is in closed state
4 Replies
d.js toolkit
d.js toolkit•5mo ago
duck
duck•5mo ago
this is your reminder that discord.js is not a language, but rather just an api wrapper you cannot "code a mysql database with discord.js", and this therefore belongs in #other-js-ts also even though you're hosting locally, I'd still suggest not posting your credentials publicly on principle
Sambeano
SambeanoOP•5mo ago
I didn't even realize I posted that 😅 fixed that part and will be moving it
d.js toolkit
d.js toolkit•5mo ago
The thread owner has marked this issue as solved.

Did you find this page helpful?