Search code examples
javascriptnode.jsdiscorddiscord.js

What is the best way to ban an user from all the servers the bot is in without api spamming?


is there a better way than this one to ban an user from all the servers the bot is in without api spamming?

client.guilds.cache.forEach(a => a.members.ban(targetID))

Solution

  • NOTE:

    This is against Discord's ToS, and you should not use it.

    CODE:

    I will still provide code for the sake of knowledge.

    You can use setInterval() to wait an amount of time before banning.

    client.guilds.cache.forEach(a => {
      setInterval(() => {
        a.members.ban(targetID);
      }, 2000)
    })