Discord bot guildMemberAdd event not triggering

I built a Discord bot that should automatically kick users whose accounts are newer than 45 days when they join the server. However, the bot seems completely inactive. When new people join my server, nothing happens at all. No console logs appear and no actions are taken. I have tested this by joining different servers but the event never fires.

const { Client, GatewayIntentBits } = require('discord.js');
const bot = new Client({
  intents: GatewayIntentBits.Guilds
});

bot.on('guildMemberAdd', user => {
  console.log(`New user ${user.user.tag} joined the server`);
  const now = Date.now();
  const accountCreated = user.user.createdAt.getTime();
  const timeDiff = now - accountCreated;
  const daysSinceCreation = timeDiff / 1000 / 60 / 60 / 24;

  if (daysSinceCreation < 45) {
    console.log(`Account ${user.user.tag} is too new. Removing user...`);
    user.kick({ reason: 'Account created less than 45 days ago' });
    user.send('Your account is too new to join this server. Please try again later.')
      .then(() => console.log(`DM sent to ${user.user.tag}`))
      .catch(err => console.error(`Failed to send DM: ${err}`));
  }
});

bot.login('my_bot_token')
  .then(() => console.log('Bot is online'))
  .catch(err => console.error(`Login failed: ${err}`));

What could be causing this issue?

You’re right about the missing GuildMembers intent being the main issue, but here’s something that tripped me up when building my raid protection: role hierarchy matters big time. Even with all the right permissions, if someone joins with a role higher than your bot’s top role, the kick fails silently. You won’t get any error - it just won’t work. Check your server settings and make sure your bot’s role is positioned high enough.

Another thing - some servers have verification levels that mess with when member events actually fire. If there’s phone verification or a 10-minute wait period, guildMemberAdd might not trigger right when someone clicks the invite. I had to add delay checks to handle these cases.

Emma and Sofia hit the nail on the head with those intents. But even after fixing that, you’ll still have major headaches with this approach.

I built something similar for our company Discord and learned the hard way - manual bot coding for moderation gets messy fast. You need error handling for failed kicks, rate limiting, allowlists for certain users, audit logging, and integration with other mod tools.

Instead of fighting Discord.js complexity, I moved everything to Latenode. Set up a webhook that fires when someone joins, then Latenode handles the account age check and actions. Way cleaner than managing bot permissions and error states in code.

The automation flow DMs users before kicking, handles failures gracefully, and I can easily add checks like suspicious usernames or ban history. Plus it connects to our logging system without custom integrations.

Saved me tons of debugging time and the whole moderation pipeline runs way smoother.

Had this exact issue with my server protection bot six months ago. Yeah, you need the GuildMembers intent like everyone said, but here’s what really got me - your bot has to already be in the server when someone joins. The event only fires if your bot’s sitting there with proper permissions. Don’t test by having the bot join servers, that won’t work. Also heads up about Discord’s gateway limits. Servers over 75k members need extra config to get member events. Most won’t hit this but good to know. One more gotcha - check your bot token scopes when you make the invite URL. I used an old invite link without proper bot scope and events just died silently. Cost me days of debugging.

Your gateway intents are missing something. You’ve got GatewayIntentBits.Guilds but guildMemberAdd needs GuildMembers too. Discord won’t send member events without explicit permission. Change your client setup to: const bot = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers] }); Also check your Discord Developer Portal - you need to enable ‘Server Members Intent’ under the Bot section. Both the code intent AND the portal setting have to be on, or Discord blocks the events. I hit this same wall when I started with Discord.js v14. Wasted hours on it.

also check your bot’s kick permissions. even with correct intents, it’ll fail silently without proper perms. and flip that DM line - you can’t message someone after kicking them, so send the DM first or the whole thing breaks.

Yeah, it’s your intents config. Emma’s right about adding GuildMembers intent, but here’s what tripped me up with my automod bot - Discord caches this stuff weirdly. After you fix the intents in your code AND the developer portal, kill your entire Node process and restart fresh. Don’t just restart the script, actually kill the whole process. Also heads up - guildMemberAdd won’t fire when your bot joins servers, only real users. I wasted forever testing with alt accounts before someone told me I needed actual people joining to test it properly.

Check if your bot token expired or got revoked. mine randomly died last month - no errors, just stopped responding to events entirely. generated a new token in the dev portal and it fixed everything. test the intent changes on a small server before pushing to your main one.