NightDev Community Forums

Nightbot !Joke Command


#1

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

!commands add !joke -cd=5 $(eval var jokes = “$(urlfetch json https://pastebin.com/raw/RL6bTv7T) “.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.


#2

@WaterBubblez

Try this:

!addcom -cd=5 !joke $(eval a=$(urlfetch json https://pastebin.com/raw/RL6bTv7T).split(`,`);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.


#3

@RokettoJanpu
Now sometimes the bot replies with “undefined” .


#5

This should work a little better:

!addcom -cd=5 !joke $(eval a=$(urlfetch json https://pastebin.com/raw/RL6bTv7T).split(`,`);a[Math.floor(Math.random()*(a.length-1))])

#6

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

!addcom -cd=5 !lifehack $(eval a=$(urlfetch json https://pastebin.com/raw/ssvJnRkN).split(,);a[Math.floor(Math.random()*(a.length-1))])

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


#7

@WaterBubblez

!addcom -cd=5 !lifehack $(eval a=`$(urlfetch json https://pastebin.com/raw/ssvJnRkN)`.split(`,`);a[Math.floor(Math.random()*(a.length-1))])

#8

Thanks again, but why the difference between now and the command before?


#9

https://pastebin.com/raw/RL6bTv7T has quotation marks surrounding the text.

https://pastebin.com/raw/ssvJnRkN does not.

I had to adjust the code to accommodate for this.


#10

Ah, gotcha. Thanks again