A random response out 50 responses

Hi I’m trying to make it so I can have nightbot call a random response out of the 50 I have made, but you can only have 500 characters in a command. So how would I go about doing this? I tried to make nightbot call to multiple commands

$(eval a=["!listofresponse1", “!listofresponse2”];a[Math.floor(Math.random() * a.length)])

but I don’t think nightbot can call another comand so what is the best way to go about doing this?

I would recommend using a pastebin link and using $(urlfetch json) to fetch it as this bypasses the 500 character limit.

How would I go about it generating a random bullet point from that list?

I’m assuming your asking how to format the list.
The simplest way would be separating the responses by semicolons like this:


You don’t need a semicolon after the last response.
Here’s what it world looks like on the command side:

$(eval a="$(urlfetch json https://pastebin.com/raw/xxxxxx)".split(";"):a[Math.floor(Math.random()*a.length)])

Hope this helped :slight_smile:

1 Like

I keep getting unexpected identifier or unexpected token ‘:’

I’m assuming I get rid of the Quotation marks around the red text and replace it with how I have it set up

Actually that’s a mistake on my end the “:” after the .split(";"): should be a “;” and look like .split(";");
Sorry for any inconvenience this may have caused.

It’s all good man. I really appreciate you helping me out. Unfortunately I get the Remote Server Returned Code 403 error now

Most likely you aren’t using the raw pastebin link if I had to guess. You need to use the raw link so it returns plain text. Either that or the pastebin your linking doesn’t exist. If it’s neither of those make sure you included the json after the url fetch and before the link.

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