discord_bot/server/convertCustomCommandsJSONToSQL.js
SileNce5k 3c8bec050d
All checks were successful
CI / CI (push) Successful in 22s
Lint Codebase / eslint (push) Successful in 15s
Add convertion of custom commands
2024-12-17 10:39:30 +01:00

40 lines
1.2 KiB
JavaScript

const sqlite3 = require('sqlite3').verbose();
module.exports = async function () {
const customCommands = require('../data/customCommands.json')
const db = new sqlite3.Database('data/database.db');
return new Promise((resolve, reject) => {
customCommands.forEach(element => {
});
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();
})
}