I'm trying to make a command that repeats a message based on the number that you input. For example, if I did -ping 4 it would say pong back 4 times. My code for the functionality of the command at the moment (separate from the main file) is:
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');
});
}
However the bot only returns with one command. Help would be much appreciated, thanks!
I'm using the latest Discord.js, VSCode, and node.js.
With await message.channel.messages.fetch({limit: args[1]})
you are fetching the channel's messages with a limit of whatever number they provided.
If you would like to send a message to the channel however many times they provided, you could use this:
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');
}
}
}
Notice the for loop at the bottom used to send the messages.