recently I made a discord bot that bans new members automaticly when someone who created their account less then 30 days ago joins.The problem is that when someone joins nothing happens and neither the log shows anything.Wondering what could be the problem.thanks!!
`const { Client, Intents,GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: GatewayIntentBits.Guilds
});
client.on('guildMemberAdd', member => {
console.log(`${member.user.username} csatlakozott a szerverhez.`);
const currentTime = Date.now();
const creationTime = member.user.createdAt.getTime();
const ageInMs = currentTime - creationTime;
const ageInDays = ageInMs / 1000 / 60 / 60 / 24;
if (ageInDays < 30) {
console.log(`${member.user.username} fiókja egy hónapnál fiatalabb. Bannolás és üzenet küldése...`);
member.ban({ reason: 'Fiók létrehozási dátuma egy hónapnál fiatalabb' });
member.send('Sajnáljuk, de a fiókod egy hónapnál fiatalabb, így nem tudsz csatlakozni a szerverhez.')
.then(() => console.log(`Üzenet elküldve ${member.user.username}-nek.`))
.catch(error => console.error(`Hiba történt az üzenet küldése közben: ${error}`));
}
});
client.login('token')
.then(() => console.log('Bot bejelentkezve.'))
.catch(error => console.error(`Hiba történt a bejelentkezés közben: ${error}`));
`
tried: Joining several servers, the log should of show the join, and automaticly ban the member.