From 11cb1c52603e7b020f020f87885299bb626e1a0b Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Thu, 2 Jan 2025 13:09:34 -0700 Subject: [PATCH] uhhhhhhh --- discordJoins.js | 30 +++++++++++++++++++ migrations/010_init_gameAnalytics_table.sql | 3 ++ migrations/011_init_globalAnalytics_table.sql | 4 +++ 3 files changed, 37 insertions(+) create mode 100644 discordJoins.js create mode 100644 migrations/010_init_gameAnalytics_table.sql create mode 100644 migrations/011_init_globalAnalytics_table.sql diff --git a/discordJoins.js b/discordJoins.js new file mode 100644 index 0000000..0804f72 --- /dev/null +++ b/discordJoins.js @@ -0,0 +1,30 @@ +const pool = global.db_pool +const client = global.discord_client +module.exports = async (member) => { + const conn = await pool.getConnection() + console.log('Member joined:', member.displayName); + // Check database, if discordId is banned and the ban isn't expired, kick the user for the short reason + conn.query( + 'SELECT * FROM bans WHERE discordId = ?', + [member.id.toString()], + (error, results) => { + console.log("Start results") + if (error) { + console.error('Error checking ban:', error); + return; + } + + if (results.length === 0) { + return console.log('No ban found'); + } + + const ban = results[0]; + if (ban.expiresTimestamp && new Date(ban.expiresTimestamp) < new Date()) { + return console.log; + } + console.log('Banned:', ban); + + member.kick(`Banned: ${ban.reason}`).catch(console.error); + } + ).finally(() => conn.release()); +} \ No newline at end of file diff --git a/migrations/010_init_gameAnalytics_table.sql b/migrations/010_init_gameAnalytics_table.sql new file mode 100644 index 0000000..d6964f3 --- /dev/null +++ b/migrations/010_init_gameAnalytics_table.sql @@ -0,0 +1,3 @@ +CREATE TABLE IF NOT EXISTS gameAnalytics ( + gameID INT PRIMARY KEY NOT NULL +); \ No newline at end of file diff --git a/migrations/011_init_globalAnalytics_table.sql b/migrations/011_init_globalAnalytics_table.sql new file mode 100644 index 0000000..3db9e3e --- /dev/null +++ b/migrations/011_init_globalAnalytics_table.sql @@ -0,0 +1,4 @@ +CREATE TABLE IF NOT EXISTS globalAnalytics ( + tag VARCHAR(255) PRIMARY KEY NOT NULL, + value INT NOT NULL DEFAULT 0 +); \ No newline at end of file