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.
@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.
@RokettoJanpu
Now sometimes the bot replies with “undefined” .
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))])
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 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,”
@WaterBubblez
!addcom -cd=5 !lifehack $(eval a=`$(urlfetch json https://pastebin.com/raw/ssvJnRkN)`.split(`,`);a[Math.floor(Math.random()*(a.length-1))])
Thanks again, but why the difference between now and the command before?
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.
system
Closed
January 31, 2019, 1:31am
11
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.