I am new to javascript. I cant find a way to do this anywhere.
I am expecting this:
function sendInChannel(channel, msg, MessageCount){
for (let i = 0; i < MessageCount; i++) {
channel.send(msg)
}
}
to not pause the entire script. This is a discord.js function, and i want it to send multiple messages at once instead of this function waiting about 0.1 seconds and yielding it.
>Solution :
Use Promises and async/await to make it asynchronous:
async function sendInChannel(channel, msg, messageCount) {
for (let i = 0; i < messageCount; i++) {
await channel.send(msg);
}
}