NightDev Community Forums

Commands returns [Error Connecting To WebEval Service]

#1

Hii guys, Thank you for taking your time reading this and replying!
i saw other post similiar to mine and i tried out what they did but it didnt work for me! :frowning:

When i use my commands sometimes it works perfectly and sometimes it respond with:
[Error Connecting To WebEval Service]

This is what i have in my commands return:
$(eval q=decodeURIComponent("$(querystring)"); var jokes = $(urlfetch json https://pastebin.com/raw/dRZSZbxL).split(","); jokes[Math.floor(Math.random() * jokes.length)])

I do not know much about Nightbot and how it all works so please forgive me if i made a noob mistake or anything :frowning:

If someone knows how to fix my problem, ill be thankfull for ever!
Sorry for bad english, i tried to fix some grammer mistakes!

Have a nice day!
Drahsin

0 Likes

#2

that is not a proper json format, thus error occur, you can refer to the correct format by using w3school.

0 Likes

#3

I looked it up but i have no knowledge about this kind of stuff, Is there a way that you maybe can help me ouy?

0 Likes

#4

@drahsin

The last line in the pastebin link contains a comma, therefore running a split() with a comma separator will result in an array of jokes where the last item is just an empty string. If Nightbot chooses to output this empty string, it will instead output “[Error Connecting to WebEval Service]”. The following code should accommodate for the extra comma:

$(eval a=$(urlfetch json https://pastebin.com/raw/dRZSZbxL).split(`,`);a[Math.floor(Math.random()*(a.length-1))])
0 Likes

#5

Thank you alot! i think i do understand a little what you said.
correct me if im wrong but seems like i had to remove the last comma?
But again, thank you alot for helping out. appreciate it !

0 Likes

#6

The code I posted above already takes the last comma into account, so there is now no need to remove it.

0 Likes

#7

okay awesome! got it

0 Likes

closed #8

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

0 Likes