Reading a random line from a text file

I have this command that I currently have on my sight that my users love, and I am trying to bring it over into Phantombot, but it doesn’t seem to work. Basically I am trying to read a random line from a text file. This is the command/response that I can’t see to get working.


It’s not reading the file at all, it just shows that line in the chat. I’m not a JavaScript developer so any help would be appreciated.


There is no “readrandline” method in PhantomBot. Just get the array with

> $.readFile('ADMG_RPS_' + arg[1] + '.txt')

. And call a random index on this.

There is a command variable (readfilerand) which can do this. More information:

If you want to use it in a JS script, you can look into the customCommands.js to see what (readfilerand) is doing.

1 Like

ah :slight_smile: nice to know - didn’t know that.