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

110
Views
¿Cómo recopilar varios mensajes en un bucle usando awaitMessage?

Estoy tratando de crear un comando de juego en el que los jugadores deben adivinar dónde está el gato entre varias cajas. Se hizo el concepto básico, pero de alguna manera no puedo recopilar más de 1 mensaje, detendría el proceso después de recopilar el primero.

El código:

 const Command = require("../structures/Command.js"); module.exports = new Command({ name: "cat", async run(message, args, client) { //Preparing stuff var i = 0; var cat = Math.floor(Math.random()*5)+1; message.channel.send("A wild cat have appeared and hiden in 5 random boxes, can you find it?") const filter = (user) => { return user.author.id === message.author.id }; //Loop while (i<10) { console.log(cat); let collected = await message.channel.awaitMessages(filter, { max: 1, time: 15000, errors: ['time'] }); answer = collected.first().content; console.log(answer) //checking if (answer === cat){ message.reply("You opened the correct box!"); var i = 727; console.log("Yes") } else { var move = Math.floor(Math.random()*10)+1; if (cat===1){var move = 1} else if (cat===5){var move = 10} if (move<5){var cat = cat+1} else {var cat = cat-1} var i = i + 1; var days = 10 - cat; console.log(cat) message.channel.send(`You didn't guessed the correct box, the cat has now moved to another box. You got ${days} tries left`) } } } });
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!