Improve whitelist feature
All checks were successful
CI / CI (push) Successful in 1m24s

* Use a primary autoincrementing primary key because primary keys need
  to be unique
* Cache whitelist on bot startup / only read from database once
* "Externalize" whitelist checking to the messageCreate function.
This commit is contained in:
SileNce5k 2025-04-30 15:55:53 +02:00
parent c9d7a54e25
commit a066fd0662
Signed by: SileNce
GPG key ID: B0A142BB4291B204
6 changed files with 81 additions and 71 deletions

View file

@ -1,6 +1,7 @@
const fs = require('fs');
const createInitialConfig = require("./util/createInitialConfig")
const convertJSONToSQL = require('./util/timer/convertJSONToSQL');
const sqlite3 = require('sqlite3').verbose();
if(!fs.existsSync("./data/config.json")) {
createInitialConfig();
}
@ -18,8 +19,8 @@ async function checkAndConvertJSONToSQL(){
}
const createDatabaseTables = require('./server/createDatabaseTables');
const createLastfmTable = require('./server/createLastfmTable');
const createWhitelistTable = require('./server/createWhitelistTable.js')
createWhitelistTable();
const createAndLoadWhitelistTable = require('./server/createAndLoadWhitelistTable.js')
createLastfmTable();
checkAndConvertJSONToSQL();
const { Collection, Client, GatewayIntentBits, Partials } = require('discord.js');
@ -43,8 +44,11 @@ const {
client.settings = new Collection();
client.commands = new Collection();
client.serverPrefixes = new Collection();
client.whitelist = new Collection();
createAndLoadWhitelistTable(client.whitelist);
client.settings.set("presenceType", presenceType);
client.settings.set("presenceText", presenceText);