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

389
Views
¿Cómo puedo agregar un tiempo de reutilización en el comando de trabajo (economía, moneda)

Así que estoy tratando de hacer un bot de discordia económico, pero no sé cómo hacer un tiempo de reutilización de 3 horas en el comando de trabajo después de que el usuario lo use, así que para los que no entienden

yo: !trabajo

bot: obtuviste 123 dinero mientras trabajabas.

yo: !trabajo

bot: tienes que esperar 3 horas antes de volver a trabajar.

Este es mi código para el comando de trabajo.

 if (message.content.toLowerCase().startsWith(prefixS.prefix + 'work')) { const inventoryS = await inventory.findOne({ userID: message.author.id, guildID: message.guild.id }); const payment = Math.floor(Math.random() * 200); inventoryS.work = parseInt(payment) inventoryS.save() message.channel.send({ embeds: [new Discord.MessageEmbed().setAuthor(message.author.username).setTitle('⚒️⚒️').setColor('BLUE')] }).then((message) => { setTimeout(function () { function doRandHT() { var rand = [`You worked an extra night and got ${inventoryS.work}`, `You worked an extra day and got ${inventoryS.work}`, `Your boss just gave you ${inventoryS.work} for just sitting in your chair`]; return rand[Math.floor(Math.random() * rand.length)]; } message.edit({ embeds: [new Discord.MessageEmbed().setTitle(doRandHT()).setColor('BLUE')] }).then(() => { inventoryS.currency = parseInt(inventoryS.currency) + parseInt(inventoryS.work) inventoryS.save() } }); }) }, 3000) }) }

Gracias

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esta es la guía para el enfriamiento en discord.js v12, es similar si está usando v13.

En el archivo de comandos:

 module.exports = { name: 'example', cooldown: 5, execute(message) { // ... }, };

En el archivo principal:

 client.cooldowns = new Discord.Collection(); const { cooldowns } = client; if (!cooldowns.has(command.name)) { cooldowns.set(command.name, new Discord.Collection()); } const now = Date.now(); const timestamps = cooldowns.get(command.name); const cooldownAmount = (command.cooldown || 3) * 1000; if (timestamps.has(message.author.id)) { const expirationTime = timestamps.get(message.author.id) + cooldownAmount; if (now < expirationTime) { const timeLeft = (expirationTime - now) / 1000; return message.reply(`please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`); } } timestamps.set(message.author.id, now); setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);

Asegúrese de ejecutar este código antes de ejecutar el comando.

about 4 years ago · Juan Pablo Isaza Report
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!