Nightbot sometimes returns undefined or nothing

Asked Mar 12, 2024·2 replies·Last activity 2 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

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

IMG_20240308_170408.jpg

2 replies

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

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