Nightbot sometimes returns undefined or nothing

Trying to make a custom funny command.
2 pastebins, in each pastebin contains a lot of strings(for test there are only 3 strings in each pastebins).
Overall, all works, but sometimes Nightbot returns “undefined” or even nothing
Here is a command

$(eval r = (a) => a[Math.floor(Math.random() * a.length - 1)]; s = (s) => s.split(#); i = s($(urlfetch json https://pastebin.com/raw/dWVGj6sP)); j = s($(urlfetch json https://pastebin.com/raw/n9FjG8bS)); $(user) ${r(i)}, $(touser) ${r(j)}; )

(Add a space before last “)” because “;)” is a smile, in original there is no space
Here is a pic with some results

Zero ideas what’s the problem.

P.S. also, i change all strings in both pastebins to English, but in original all strings are on a different language. In English Nightbot never return nothing, but on russian - sometimes he does.
P.P.S. both pastebins have space in the end of the line after symbol “#”, i tried to remove them and remove “-1” after “a.length”, but it doesn’t help

i’m not sure if it’ll fully fix the issue… but i would remove the "#" on the last line of each paste and the "-1"… if that doesn’t work, i have another idea that may also speed up the command response, or might not

2 Likes

Actually, looks like it helped.
Test it about 10m and 0 undefined was return.
Thanks a lot.

2 Likes

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