Random Nightbot response pastebin

I tried to use the other posts that I’m sure covers my issue but I couldn’t get anything to function. I just want a Nightbot to return a random response from a pastebin but every version of the commands I find on here leads to “Code generation from strings disallowed for this context”. That makes me think it’s something within the pastebin itself, but I couldn’t find anything about it either.

I need a command to just pick one of these to say please ):

neon command - Pastebin.com this is the pastebin

Hey @Taco!

That’s because your JSON array isn’t defined properly, use double quotes " instead of backticks `.

I changed it to double quotes but i dont have a command to use it still. I looked one up but it just returned:

Code generation from strings disallowed for this context

The command was:

$(eval var satfact= “$(urlfetch json neon command - Pastebin.com) “.split(”,”); satfact[Math.floor(Math.random() * (satfact.length - 1))]:wink:

edit^ the end isnt the wink emote its a semi colon and end parenthesis

My bad, I thought you had a command already. I’ve had an intense migraine these last couple days so I’m sorry if I miss some things. Poking me gently about it like you did is the way to go.

There are two options to fix your code:

• the first one is to keep your JSON in your Pastebin intact and build your code around it:
→ Pastebin:

["pepeMeltdown GO GO GO pepeMeltdown",
"pepeMeltdown GOTTA GO pepeMeltdown",
"pepeMeltdown IM OUTTA HERE pepeMeltdown"]

→ code:

$(eval satfact=$(urlfetch json https://pastebin.com/raw/XXXXXXXX); satfact[Math.floor(Math.random() * satfact.length)];)

Replace XXXXXXXX with your paste ID.

• the second option is to edit your Pastebin so it’s just strings separated by a separator and write your code around it:
→ Pastebin:

pepeMeltdown GO GO GO pepeMeltdown;
pepeMeltdown GOTTA GO pepeMeltdown;
pepeMeltdown IM OUTTA HERE pepeMeltdown

→ code:

$(eval satfact='$(urlfetch json https://pastebin.com/raw/XXXXXXXX)'.split(';'); satfact[Math.floor(Math.random() * satfact.length)];)

Replace XXXXXXXX with your paste ID.


  • the error you were receiving was because you were calling a non-raw Pastebin.
  • you would only have gotten the 2 first options at random:
    Math.floor(Math.random() * N) gives you a random integer between 0 and N-1,
    here satfact.length is equal to 3, so it’ll give you a random number between 0 and 2,
    and the first item of an array is always at index 0 and the last one at length - 1.

about the first solution:

  • you would have had an issue because you put the $(urlfetch) between double quotes " and tried to split it to build an array, when it already is an array.

about the second solution:

  • you build your array this way when you have a string as input, I replaced the comma with a semicolon since they’re less used.


I tried the first and second option but was met with the same result as before. I tried putting brackets on the pastebin to see if maybe it was that, but had no luck :confused:

P.S. Sorry about your migraine ):

It’s working for me

Code: $(eval arr='$(urlfetch json https://pastebin.com/raw/xxxxxxxx)'.split(';'); arr[Math.floor(Math.random()*arr.length)])


1 Like

Thanks! This command worked for me.

1 Like

It didn’t work because you omitted the raw in the Pastebin link.


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