mirror of
https://github.com/Burn-E99/TheArtificer.git
synced 2026-06-04 09:03:50 -04:00
update db structure to let init work correctly
This commit is contained in:
14
src/db/client.ts
Normal file
14
src/db/client.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import config from '../../config.ts';
|
||||
import { Client } from '../../deps.ts';
|
||||
import { LOCALMODE } from '../../flags.ts';
|
||||
|
||||
const dbClient = await new Client().connect({
|
||||
hostname: LOCALMODE ? config.db.localhost : config.db.host,
|
||||
port: config.db.port,
|
||||
db: config.db.name,
|
||||
username: config.db.username,
|
||||
password: config.db.password,
|
||||
debug: true,
|
||||
});
|
||||
|
||||
export default dbClient;
|
||||
20
src/db/common.ts
Normal file
20
src/db/common.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import dbClient from './client.ts';
|
||||
|
||||
type UserIdObj = {
|
||||
userid: bigint;
|
||||
};
|
||||
|
||||
// List of userIds who have requested that the bot ignore them
|
||||
export const ignoreList: Array<bigint> = [];
|
||||
const dbIgnoreList = await dbClient.query('SELECT * FROM ignore_list');
|
||||
dbIgnoreList.forEach((userIdObj: UserIdObj) => {
|
||||
ignoreList.push(userIdObj.userid);
|
||||
});
|
||||
|
||||
export const weekDays = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
|
||||
|
||||
export const queries = {
|
||||
insertRollLogCmd: (api: number, error: number) => `INSERT INTO roll_log(input,result,resultid,api,error) values(?,?,?,${api},${error})`,
|
||||
callIncCnt: (cmdName: string) => `CALL INC_CNT("${cmdName}");`,
|
||||
callIncHeatmap: (dateObj: Date) => `CALL INC_HEATMAP("${weekDays[dateObj.getDay()]}", ${dateObj.getHours()});`,
|
||||
};
|
||||
Reference in New Issue
Block a user