Lurk Command Is Not Working Properly

Good day!

I moderate for a streamer and we use this code for our !lurk command:

$(user) $(eval a=“$(urlfetch json https://pastebin.com/raw/HCHq9h41)”.split(“;”);a[Math.floor(Math.random()*a.length)]) caffei125Love

The command works sporadically, sometimes it works, and sometimes it gives this [Error Connecting To WebEval Service] message. I’m at a loss already as to what is causing this, pI need assistance in resolving this.

Hey @emptymerchant!

Usually such errors happen rarely and you can’t do anything about it beside waiting as it’s an overload on Nightbot’s side.

However, in your case it’s likely more frequent than for others, and that’s because of how you wrote your code: you create an array where the last item is empty, and that breaks the execution of the code from Nightbot’s side when it tries to send an empty message; you have three options to solve your issue (only use one of them, don’t use two or more at the same time):

  • remove the last semi-colon (;) in your Pastebin,
  • use the array’s length minus one when you pick at random: a.length - 1 ,
  • remove the last item from the array: add a.pop(); between the .split() and random statement.

Note: I’d personally use another separator than a semi-colon, a vertical bar (|) for example, because JavaScript uses semi-colons to end instructions, so it could confuse the live compiler, while a vertical bar by itself represents nothing (two vertical bars next to each other (||) are a or statement tho’).

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