Estoy tratando de hacer un comando que repita un mensaje basado en el número que ingresaste. Por ejemplo, si hiciera -ping 4 diría pong back 4 veces. Mi código para la funcionalidad del comando en este momento (separado del archivo principal) es:
async execute(message, args) { if(!args[1]) return message.channel.send("`Command Usage:\n-rqplay (amount)`"); if(isNaN(args[1])) return message.channel.send("Please enter an actual number idiot :rolling_eyes:"); if(args[1] > 15) return message.channel.send("I don't want to send that many messages :nauseated_face:"); if(args[1] < 1) return message.reply("Bro come on, are this stupid?"); await message.channel.messages.fetch({limit: args[1]}).then(_messages =>{ message.channel.send('@everyone play'); }); }
Sin embargo, el bot solo regresa con un comando. La ayuda sería muy apreciada, gracias!
Estoy usando los últimos Discord.js, VSCode y node.js.
Con await message.channel.messages.fetch({limit: args[1]})
está recuperando los mensajes del canal con un límite de cualquier número que hayan proporcionado.
Si desea enviar un mensaje al canal, independientemente de las veces que lo hayan proporcionado, puede utilizar este:
async execute(message, args) { if(!args[1]) return message.channel.send("`Command Usage:\n-rqplay (amount)`"); if(isNaN(args[1])) return message.channel.send("Please enter an actual number idiot :rolling_eyes:"); if(args[1] > 15) return message.channel.send("I don't want to send that many messages :nauseated_face:"); if(args[1] < 1) return message.reply("Bro come on, are this stupid?"); for (let i = 0; i < args[1]; i++) { message.channel.send('@everyone play'); } } }
Observe el bucle for en la parte inferior que se usa para enviar los mensajes.