1
1
mirror of https://github.com/Burn-E99/TheArtificer.git synced 2026-06-04 00:53:50 -04:00

Added Audit system, Guild auditing put on hold

This commit is contained in:
Ean Milligan (Bastion)
2022-05-28 02:07:00 -04:00
parent b7f9fc852a
commit a01b8b8fd2
13 changed files with 204 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ await dbClient.execute(`USE ${config.db.name}`);
console.log('DB created');
console.log('Attempt to drop all tables');
await dbClient.execute(`DROP VIEW IF EXISTS db_size;`);
await dbClient.execute(`DROP TABLE IF EXISTS allowed_channels;`);
await dbClient.execute(`DROP TABLE IF EXISTS all_keys;`);
await dbClient.execute(`DROP TABLE IF EXISTS allowed_guilds;`);
@@ -110,5 +111,20 @@ await dbClient.execute(`
`);
console.log('Table created');
// Database sizes view
console.log('Attempting to create view db_size');
await dbClient.execute(`
CREATE VIEW db_size AS
SELECT
table_name AS "table",
ROUND(((data_length + index_length) / 1024 / 1024), 3) AS "size",
table_rows AS "rows"
FROM information_schema.TABLES
WHERE
table_schema = "${config.db.name}"
AND table_name <> "db_size";
`);
console.log('View Created');
await dbClient.close();
console.log('Done!');

View File

@@ -10,7 +10,7 @@ await dbClient.execute('INSERT INTO all_keys(userid,apiKey) values(?,?)', [confi
console.log('Inesrtion done');
console.log('Attempting to insert default commands into command_cnt');
const commands = ['ping', 'rip', 'rollhelp', 'help', 'info', 'version', 'report', 'stats', 'roll', 'emojis', 'api', 'privacy', 'mention'];
const commands = ['ping', 'rip', 'rollhelp', 'help', 'info', 'version', 'report', 'stats', 'roll', 'emojis', 'api', 'privacy', 'mention', 'audit'];
for (const command of commands) {
await dbClient.execute('INSERT INTO command_cnt(command) values(?)', [command]).catch((e) => {
console.log(`Failed to insert ${command} into database`, e);