Reputation: 43
I am getting Error: Please make sure that the message parameter is a string!
.
How do I return an array of text from my text file and auto-send that from the loop?
// read contents of the file
const data = fs.readFileSync('mr_robot.txt', 'UTF-8');
const lines = data.split(/\r?\n/);
let n_lines = 1;
for (let l_indx = 0; l_indx < lines.length; l_indx++) {
var message = lines
}
autosend.PostLoop(message, channelID, tokenID, minimum, maximum)
Example text from .txt
Hey! Hey! Hey! Boy's not picking up.
Okay, okay, okay.
I got you, man.
I didn't know that.
All right, I got you.
All right.
Yeah, you got me confused.
Upvotes: 0
Views: 228
Reputation: 3582
It looks like you are assigning message to your original array lines
. You are looping but not indexing anything.
I'm not exactly sure what you are trying to achieve but if you want to call PostLoop
per message you need to do something like this:
const data = fs.readFileSync('mr_robot.txt', 'UTF-8');
const lines = data.split(/\r?\n/);
let n_lines = 1;
for (let l_indx = 0; l_indx < lines.length; l_indx++) {
var message = lines[l_indx];
autosend.PostLoop(message, channelID, tokenID, minimum, maximum);
}
Upvotes: 1