sql: javascript > typescript
This commit is contained in:
parent
c3badac626
commit
d44ad19efc
4 changed files with 11 additions and 7 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,3 +2,5 @@ node_modules
|
|||
.env
|
||||
pnpm-lock*
|
||||
dist
|
||||
*.db
|
||||
*.sqlite*
|
3
index.ts
3
index.ts
|
@ -3,7 +3,7 @@ import { WebhookClient, EmbedBuilder, Embed } from 'discord.js';
|
|||
import { Worker } from 'worker_threads';
|
||||
import { asyncInterval, addNotation } from './src/helperFunctions';
|
||||
import { string } from 'prismarine-nbt';
|
||||
|
||||
import { InitTable } from './src/sqlFunctions';
|
||||
import { loadConfig } from './src/configLoader';
|
||||
const config = loadConfig();
|
||||
|
||||
|
@ -24,6 +24,7 @@ const bazaarPrice = {
|
|||
};
|
||||
|
||||
async function initialize() {
|
||||
await InitTable();
|
||||
const matches = process.env.WEBHOOK_URL.match(webhookRegex);
|
||||
if (!matches) return console.log(`[Main thread] Couldn't parse Webhook URL`);
|
||||
const webhook = new WebhookClient({ id: matches[1], token: matches[2] });
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"open": "^8.4.2",
|
||||
"prismarine-nbt": "^2.7.0",
|
||||
"socket.io": "^4.8.1",
|
||||
"sqlite3": "^5.1.7",
|
||||
"toastify-js": "^1.12.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.7.2"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const sqlite3 = require('sqlite3').verbose();
|
||||
import sqlite3 from 'sqlite3';
|
||||
|
||||
//TODO
|
||||
// MUTEX functions for adding/removing/upsert
|
||||
|
@ -28,7 +28,7 @@ async function InitTable() {
|
|||
db.close();
|
||||
}
|
||||
}
|
||||
function runQuery(db, query , params = []) {
|
||||
function runQuery(db: sqlite3.Database, query: string, params: string[] = []) {
|
||||
return new Promise((resolve,reject) => {
|
||||
db.run(query, params, function (err) {
|
||||
if(err){
|
||||
|
@ -40,7 +40,7 @@ function runQuery(db, query , params = []) {
|
|||
});
|
||||
});
|
||||
}
|
||||
function getQuery(db, query, params = []) {
|
||||
function getQuery(db: sqlite3.Database, query: string, params: string[] = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
db.get(query, params, (err, row) => {
|
||||
if (err) {
|
||||
|
@ -51,7 +51,7 @@ function getQuery(db, query, params = []) {
|
|||
});
|
||||
});
|
||||
}
|
||||
function allQuery(db, query, params = []) {
|
||||
function allQuery(db: sqlite3.Database, query: string, params: string[] = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
db.all(query, params, (err, rows) => {
|
||||
if (err) {
|
||||
|
@ -63,6 +63,6 @@ function allQuery(db, query, params = []) {
|
|||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
InitTable
|
||||
}
|
Loading…
Reference in a new issue