So I have this command, that'll basically mute everyone in a voice channel, besides people with a certain role, and it works perfectly!
But what I also want it to do it take like a second or two inbetween mutes so I'm not API spamming, and get banned from using discord.js, so how would I do that?
Code:
message.delete({ timeout: 150 });
const vc = message.member.voice.channel;
if (!vc) return message.reply("You must be in a voice channel to run this!").then(msg => {
msg.delete({ timeout: 5000 })
})
let users = vc.members.filter(member => !member.roles.cache.has("753465550604075039")).map(fn => `<@${fn.id}> | ID: ${fn.id}`)
let mutinguser = vc.members.filter(member => !member.roles.cache.has("753465550604075039"))
if (mutinguser.size === 0) return message.channel.send("There's no one to mute!")
if (mutinguser.size > 10) return message.channel.send(`I can only mute 10 people at a time! There's ${mutinguser.size} users in this voice channel!`)
mutinguser.array().forEach(m => m.voice.setMute(true))
let muting = new Discord.MessageEmbed()
.setColor("GREEN")
.setTitle(`Muting Users in [${vc.name}]`)
.setDescription(users)
.setFooter(` Users Muting: ${users.length} \n Total Users: ${vc.members.size}`)
message.channel.send(muting)