I'm making a command where a specific role gets added to all members. The problem is that, the .forEach loop is way too fast for the API.
I know that I'll probably have to solve this with a setIntervall somehow.
module.exports.run = async (bot, message, args, level) => {
if (!args || args.length < 1) return message.reply("Must provide a role to give. Derp.");
let role = message.guild.roles.find(r => r.name == args[0])
if (!role) return message.channel.send(`**${message.author.username}**, role not found`)
let msg = await message.channel.send("Ur lazy")
message.guild.members.filter(m => !m.user.bot).forEach(member => member.addRole(role))
message.channel.send(`**${message.author.username}**, role **${role.name}** was added to all members`)
msg.delete();
}
Currently this just gives Timeout errors, which is highly unwanted, so I need to do the same thing but slower.