title: setInterval/setTimeout problem getting messages at once
body: <p>i got a part of code that should send message in discord every x second but it awaits x seconds and sends all messages at once</p>
  <pre><code>let amount = 5;
  let interval = 3000
  for (i = 0; i &lt; amount; i++) {
    setInterval(() =&gt; {
      message.channel.send($arr[Random(0, $arr.length)]);
    }, interval);
  }
  </code></pre>
  <p>I tried this outside the loop , with setTimeout() and clearInterval() or clearTimeout() it never worked</p>
  <p><strong>EDIT:</strong></p>
  <pre><code>let amount = 5;
  const interval = 300; // 3000
  const tId = setInterval(() =&gt; {
    console.log(amount)
    // message.channel.send($arr[Random(0, $arr.length)]);
    if (--amount === 0) clearTimeout(tId);
  }, interval);
  </code></pre>