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.

$readrandline(ADMG_RPS_$arg1.txt)

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.

Thanks

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: https://community.phantom.bot/t/command-variables/53

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.