Nightbot !Joke Command

Hia guys, I seem to be having issues with this !joke command.

!commands add !joke -cd=5 $(eval var jokes = “$(urlfetch json “.split(”,”); jokes[Math.floor(Math.random() * (jokes.length - 1))]; )

The response I get is “Right-hand side of “instanceof” is not an object.” This appeared after I added the json in the code. Before I added that, I would get an issue of Nightbot having a 400 character limit.


Try this:

!addcom -cd=5 !joke $(eval a=$(urlfetch json`,`);a[Math.floor(Math.random()*a.length-1)]) 

Look back at the Pastebin file, joke #15. Remove the comma from the middle of the line because $(eval) is using a comma as the separator in split() and will therefore split the joke into two separate entries.

Now sometimes the bot replies with “undefined” .

This should work a little better:

!addcom -cd=5 !joke $(eval a=$(urlfetch json`,`);a[Math.floor(Math.random()*(a.length-1))])
1 Like

Hia, @RokettoJanpu thanks for helping me out last time but I have run into another error.

!addcom -cd=5 !lifehack $(eval a=$(urlfetch json,);a[Math.floor(Math.random()*(a.length-1))])

I get the same issue with “Right-hand side of “instanceof” is not an object,”


!addcom -cd=5 !lifehack $(eval a=`$(urlfetch json`.split(`,`);a[Math.floor(Math.random()*(a.length-1))])

Thanks again, but why the difference between now and the command before? has quotation marks surrounding the text. does not.

I had to adjust the code to accommodate for this.

Ah, gotcha. Thanks again

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