I am creating a security discord bot and I would like to know how to include createdAt in an event, and create a command like that .setwelcomeban 5d command (for example) which will cause all joining accounts to be automatically kicked.
            Asked
            
        
        
            Active
            
        
            Viewed 1,290 times
        
    -2
            
            
         
    
    
        Stanley
        
- 63
- 7
1 Answers
1
            You can get when a member joined a server using the joinedAt or joinedTimestamp property of a GuildMember object.
You can then loop through each member in a guild, compare the current date with the date they joined, and kick the member if they joined within the amount of days you specified.
Remember to change the /* number of days */ part to take the number of days you specify.
message.guild.members.cache.each(member => {
  const date1 = new Date(member.joinedAt).getTime();
  const date2 = new Date().getTime() - /* number of days */ * 24 * 60 * 60 * 1000;
  if (date2 < date1) {
    member.kick();
  }
});
 
    
    
        Daemon Beast
        
- 2,794
- 3
- 12
- 29