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()); }