Help picking a random variable!

I was wondering if anyone has any clue if there is some way to make this kind of command work?

!editcom !8ball :8ball:: $(eval q="$(urlfetch ".split(","); s="$(urlfetch ".split(","); x=[q + s]; "$(querystring)" == '' ? 'Please ask a question.' : q[Math.floor(Math.random() * (q.length-1))] + s[Math.floor(Math.random() * (s.length-1))];)

The x variable in the command is currently unused. Placeholder I guess?

What I’m trying to do is to have multiple responses for my 8ball split across 2 databases (in this case pastebin files), so the command will not only pick a random entry from one of the files, but also pick a random file. (out of the 2) from where to draw that sentence.

At the moment, that command will do 2 things:
1) If the user types !8ball and doesn’t say anything at all, or just types “spaces”, Nightbot will prompt them to actually ask something.
2) If the user does input any kind of query that’s not an empty space, it will draw 1 random line from each file, but place them one next to each other, which is not what I’m trying to do D: but it’s as close I’ve gotten so far to the result I want.

The need for this command was born from the fact that even though the command is supposed to only draw 1 entry/response/line from the pastebin file at a time, and 1 response is usually no longer than 20 characters… if the pastebin file itself has a total of 400 characters or more, Nightbot will say the response must be less than 400 characters anyway >_<… So I’m trying to split my responses between files to circumvent that limit (that shouldn’t be applying to begin with!).

Thanks a ton in advance for any tip you may have to contribute!

This was figured out in private messages, however if anyone else is interested here’s what I came up with:

!commands add !8ball 🎱 $(eval a="$(urlfetch".split(","); b="$(urlfetch".split(","); c=a.concat(b); "$(querystring)" == "" ? "Please ask a question." : c[Math.floor(Math.random() * (c.length-1))];)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.