diff --git a/analytics.js b/analytics.js index b239b16..cf6c274 100644 --- a/analytics.js +++ b/analytics.js @@ -13,4 +13,59 @@ module.exports = (req, res, next) => { } } ); + if (path.includes('/v1/ban/roblox/')) { + pool.query( + 'INSERT INTO globalAnalytics (tag, value) VALUES ("ROBLOX_CHECKS", 1) ON DUPLICATE KEY UPDATE value = value + 1;', + (error) => { + if (error) { + console.error('Error logging global analytics:', error); + } + } + ); + } + + if (path.includes('/v1/ban/discord/')) { + pool.query( + 'INSERT INTO globalAnalytics (tag, value) VALUES ("DISCORD_CHECKS", 1) ON DUPLICATE KEY UPDATE value = value + 1;', + (error) => { + if (error) { + console.error('Error logging global analytics:', error); + } + } + ); + } + + if (path.includes('/v1/ban/')) { + pool.query( + 'INSERT INTO globalAnalytics (tag, value) VALUES ("TOTAL_CHECKS", 1) ON DUPLICATE KEY UPDATE value = value + 1;', + (error) => { + if (error) { + console.error('Error logging global analytics:', error); + } + } + ); + } + + if (req.headers['roblox-id']) { // Roblox game ID. Insert if not exists into gameAnalytics table, if /v1/ban/roblox/:id is called incirment globalAnalytics key=TOTAL_CHECKS + pool.query( + 'INSERT INTO gameAnalytics (gameID) VALUES (?) ON DUPLICATE KEY UPDATE gameID = gameID;', + [req.headers['roblox-id']], + (error) => { + if (error) { + console.error('Error logging game analytics:', error); + } + } + ); + + if (path.includes('/v1/ban/roblox/')) { + pool.query( + 'INSERT INTO globalAnalytics (tag, value) VALUES ("ROBLOX_CHECKS_FROM_SERVERS", 1) ON DUPLICATE KEY UPDATE value = value + 1;', + (error) => { + if (error) { + console.error('Error logging global analytics:', error); + } + } + ); + } + } } \ No newline at end of file diff --git a/index.js b/index.js index 79074ad..1d39cc5 100644 --- a/index.js +++ b/index.js @@ -134,7 +134,7 @@ console.log(process.env.REASON_FLAGS) // Discord stuff const Discord = require("discord.js"); const client = new Discord.Client({ intents: ["Guilds", "GuildBans", "GuildMembers"] }) - +global.discord_client = client client.on("ready", async () => { log.info(`Logged into Discord as ${client.user.displayName}`); const commands = require("./commands") @@ -179,6 +179,8 @@ client.on("interactionCreate", async (interaction) => { } }); +client.on('guildMemberAdd', require("./discordJoins.js")) + // Startup log.info("Starting up...") const bcrypt = require("bcrypt")