Skip to content

sending multiple messages at once and giving it a delay #48

Answered by rigwild
toastyy00 asked this question in Q&A
Discussion options

You must be logged in to vote

just reset i = 0

{
  let channelIds = ['xxx', 'xxx'];
  let messages = ['wa', 'wg', 'wf', 'wy', 'wu', 'wp'];

  let i = 0;
  var loop = true;
  while (loop) {
    for (const channelId of channelIds) {
      // Send a randomly picked message
      let message = messages[Math.floor(Math.random() * messages.length)];
      await api.sendMessage(channelId, message);
      console.log(`Sent message "${message}" to channel ${channelId}`);
      await delay(1000);
    }
    i++;
    if (i >= 3) {
      i = 0;
      await delay(10 * 1000 + Math.floor(Math.random() * 5 * 1000));
    }
  }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by toastyy00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants