Rename database table functions to be clearer
All checks were successful
CI / CI (push) Successful in 19s
Lint Codebase / eslint (push) Successful in 12s

This commit is contained in:
SileNce5k 2024-11-06 01:44:16 +01:00
parent 4b53d875e4
commit 5a4cfd0a5f
Signed by: SileNce
GPG key ID: B0A142BB4291B204
4 changed files with 5 additions and 5 deletions

View file

@ -0,0 +1,32 @@
const sqlite3 = require('sqlite3').verbose();
module.exports = async function () {
const timers = require('../../data/timers.json')
const db = new sqlite3.Database('data/database.db');
return new Promise((resolve, reject) => {
for (let i = 0; i < timers.length; i++) {
let user = timers[i].user;
let reminderTime = timers[i].reminderDate;
let channel = timers[i].channel;
let customMessage = timers[i].customMessage;
let hasPassed = false;
db.run(`INSERT INTO timers (
user,
reminderTime,
channel,
customMessage,
hasPassed
) VALUES (?, ?, ?, ?, ?)`, [user, reminderTime, channel, customMessage, hasPassed], function (error) {
if (error) {
console.error(`Error while converting timers.json to SQL: ${error}`)
reject(error);
}
})
}
db.close();
console.log("Converted timers.json to SQL successfully.");
resolve();
})
}