-
{
let channelIds = ['XXXXXXXXXX', 'XXXXXXXXXX'];
let messages = ['wa', 'wg', 'wf', 'wy', 'wu', 'wp'];
var i = 1;
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) {
await delay(25 * 1000 + Math.floor(Math.random() * 5 * 1000));
}
}
} I have code like this but it always doesn't work. I want it to send 3 messages with only 1 second delay for each message, but after 3 messages are sent I want to give it a 25-30 second delay to start sending 3 messages again. |
Beta Was this translation helpful? Give feedback.
Answered by
rigwild
Nov 24, 2022
Replies: 1 comment
-
just reset {
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));
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
toastyy00
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just reset
i = 0