Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

657
Views
¿Cómo puedo hacer que mi bot cuente cuántas veces un usuario tiene un rol?

Quiero hacer un bot con discord.js v12 para contar cuantas veces un usuario tiene un rol y luego enviarlo en un canal con un webhook. Mi problema es cómo hacer que cuente el tiempo. Aquí está mi código:

 if(command === 'on') { const role = message.guild.roles.cache.find(role => role.name === '🚀On Duty') message.author.send('You are on duty') message.member.roles.add(role) message.react('<:tick:902920026489749564>') } else if(command == 'off'){ const role = message.guild.roles.cache.find(role => role.name === '🚀On Duty') message.member.roles.remove(role) let seconds = Math.floor(message.member.roles.cache.has(role.id) / 1000); let minutes = Math.floor(message.member.roles.cache.has(role.id) / 60); let hours = Math.floor(message.member.roles.cache.has(role.id) / 60); let days = Math.floor(message.member.roles.cache.has(role.id) / 24); seconds %= 60; minutes %= 60; hours %= 24; const wc = new WebhookClient('MyWebhookId', 'myWebhookUrl') const log = new Discord.MessageEmbed() .setTitle('DUTY LOGS') .setDescription(`Username: <@${message.author.id}>\n` + `Days: **${days}**\n` + `Hours: **${hours}**\n` + `Minutes: **${minutes}**\n` + `Seconds: **${seconds}**`) .setTimestamp() .setColor('#fa0505') wc.send({ username : message.author.tag, avatarURL : message.author.displayAvatarURL({ dynamic : true }), embeds : [log] }) message.react('<:tick:902920026489749564>') }

Me da esa respuesta cuando escribo !off

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!