0

I want to know if it's possible to put a time in Milliseconds in which my bot gives the role to a user once they have triggered the command for example once the user types "!Verify" the bot won't give the role to a user until a certain time, This is what i have set up for my bot to do.

bot.on('ready', () => console.log(`${bot.user.tag} has logged in fucker.`));

bot.on('message', async message => {
  if (message.author.bot) return;
  
  bot.on('guildMemberAdd', member => {
    console.log(member.user.tag);
  });

  if (message.channel.id === '695566841291997244')
    await message.delete();
  if (message.content.toLowerCase() === '!verify' && message.channel.id === '695566841291997244')
  {
    
    await message.delete().catch(err => console.log(err));
    const role = message.guild.roles.cache.get('695565873515069444');
    if(role) {
      try {
      await message.member.roles.add(role);
      console.log('Role added!');
    }
    catch(err) {
      console.log(err);
      }
    }
  }
});
jonatjano
  • 3,576
  • 1
  • 15
  • 20
  • 5
    since it is javascript you can use `setTimeout` `setTimeout( async() => { await message.member.roles.add(role); }, 5000 )` – Andre Jul 29 '20 at 08:41

1 Answers1

2

You can use the expression setTimeout()

setTimeout(async () => { 
    await message.delete().catch(err => console.log(err));
    const role = message.guild.roles.cache.get('695565873515069444');
    if(role) {
      try {
      await message.member.roles.add(role);
      console.log('Role added!');
    }
    catch(err) {
      console.log(err);
      }
    };
}, 5000);
Florian Lepage
  • 134
  • 1
  • 1
  • 8