0

I'm making some security stuff and i need blackist for user that was destroying my server and left so i cant ban them.

Here is code:

    var id_blacklist = ["some","user","id-s"]
    })
    setInterval(function(){ 
        checkUsers() 
    }, 5000);
    
    function checkUsers(){

  //here check if there is a user id that is on blacklist
}
 

EDIT: I mean to check users every 5 secconds. Because memberGuildAdd not working for no reason in my bot

1 Answers1

0

Instead of using a setInterval, use Client#guildMemberAdd to run only when someone joins.

eg.

bannedID = ['123', '456']
client.on('guildguildMemberAdd', (member) => {
  // probably check guild with member.guild

  // if their ID is in the list
  if (bannedID.has(member.id) {
    // they were banned, so do something
  }
});
mmoomocow
  • 1,173
  • 7
  • 27
  • guildguildMemberAdd not working with my bot for no reason. I tried this before i posted this question – CriDev 854 Mar 11 '21 at 09:44
  • You need to enable [privileged intents](https://stackoverflow.com/questions/64559390/none-of-my-discord-js-guildmember-events-are-emitting-my-user-caches-are-basica) – Lioness100 Mar 11 '21 at 11:52