My code has ONE error and I can't find it! Please help! (JScript)

Made up a script but I cannot fid the mistake :see_no_evil: Feel like a dummy!
Getting the error: “missing ) after argument list [:1:17]”.
Please help.
Nightbot is pulling this from pastebin:

If I do the version below, the error code is : missing ) after argument list [:1:3]

Regardless of syntax, that script is going to give you trouble for two reasons:

  • nightbot only lets you nest evals 2 deep – the eval in your bot command and the eval of the pastebin. The pastebin script can’t run an eval in it
  • The timeout length of the script execution is 1 second. so a longer delay should fail

I feel so extremely dumb! I do not understand it whatsoever :see_no_evil:
I don’t understand how to fix it or make it work…

There’s a lot going down that I’ll help breakdown. Whenever you send a command to nightbot, !hello for example, it will reply with a single message as the response. One command, one pre-set constant response. As needs for commands heighted came additional variables such as $(query) and $(urlfetch).

$(urlfetch) calls a remote url to retrieve and display a single response. It’s useful for building more complex commands that Nightbot does not support. The body that the remote url needs to return a response in plain text with less than 400 characters in its response.

Simple Urlfetch Example

This example uses a free simple text API: https://loripsum.net/

Broadcaster: !addcom !lorem $(urlfetch https://loripsum.net/api/1/short/plaintext)
Broadcaster: !lorem
Nightbot: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Bork Quid enim? Duo Reges constructio interrete. Isto modo ne improbos quidem, si essent boni viri. Quid vero? Nemo igitur esse beatus potest.

Again the need for dynamic commands became requested and thus came $(eval) which added the idea running a limited version of Javascript. $(eval) allows simple javascript commands such as $(eval 2+2) to randomizers such an 8ball command.

8Ball Command

!commands add !8ball :8ball: $(eval const responses = [‘All signs point to yes…’, ‘Yes!’, ‘My sources say nope.’, ‘You may rely on it.’, ‘Concentrate and ask again…’, ‘Outlook not so good…’, ‘It is decidedly so!’, ‘Better not tell you.’, ‘Very doubtful.’, ‘Yes - Definitely!’, ‘It is certain!’, ‘Most likely.’, ‘Ask again later.’, ‘No!’, ‘Outlook good.’, ‘Don't count on it.’]; responses[Math.floor(Math.random() * responses.length)]:wink:

In your example your loading a urlfetch of a pastebin, so Nightbot will replace this plain text into your command. If you have this urlfetch inside of another eval then your going to run into an issue running var rawText = $(urlfetch as that is not valid javascript syntax. What your attempting to do is far beyond what Nightbot’s parsing handles. Additionally any sort of AI generated code usually won’t work due to its hallucinations, Nightbot.say() doesn’t exist.

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