Answer the question
In order to leave comments, you need to log in
How to randomize between setInterval?
Hello! There is a code like this:
const fs = require('fs');
client.on('message', function (message) {
if (message.content !== "$loop") return;
fs.readFile('keys.txt', { encoding: 'utf8'}, (err, data) => {
if (err) throw err;
const linesOfFile = data.toString().split("\n");
setInterval(() => {
message.channel.send(linesOfFile.shift());
}, 10000);
});
fs.readFile('keys2.txt', { encoding: 'utf8' }, (err, data) => {
if (err) throw err;
const linesOfFile = data.toString().split("\n");
setInterval(() => {
message.channel.send(linesOfFile.shift());
}, 7000);
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question