Nighbot command, missing ) after argument list

Hi, I don’t speak English very well, so excuse me if there is an error when writing, I have a problem with this command that I am “doing” to play rock, paper or scissors, I really don’t know what is wrong and I only get missing ) after argument list
when should I use the pasterbin links if someone could guide me or tell me what I’m doing wrong I would appreciate it a lot since I’m still very new to this.

!addcom !prueba $(urlfetch https://vxrl.xyz/smm/$(eval var u=“$(touser)”;if(“$(user)”==u){var u=“$(urlfetch https://2g.be/twitch/randomviewer.php?channel=CANAL)”;}“$(user) ha retado a “+u+” jugar piedra papel o tijera”)/$(eval g=Math.floor(Math.random()*2);if(g==0){“$(user)”+" $(eval a=$(urlfetch json https://pastebin.com/raw/sYZqhNFD);a[Math.floor(Math.random()*a.length)])“}else{”$(user)“+” $(eval a=$(urlfetch json https://pastebin.com/raw/sYZqhNFD);a[Math.floor(Math.random()*a.length)])"})?i=5000&d=1)

Hey @Nou!

Using the Multiple Messages API makes things a bit more complicated, for example you can’t call other $(urlfetch) inside the API because it cuts messages at slashes, so all your API calls inside the Multiple Messages API are creating new messages, the way to make it work would be using an alias command to trigger the API once you wrote all the messages for it:

$(eval u = '$(user)'; u === '$(touser)' ? t = '$(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel))' : t = '$(touser)'; r = Math.floor(Math.random() * 2); o = $(urlfetch json https://pastebin.com/raw/XXXXXXXX); encodeURI(`${u} ha retado a ${t} jugar piedra, papel, o tijera/${r === 0 ? u : t} ${o[Math.floor(Math.random() * o.length)]}`);)

In the command above I generate both sentences to feed the Multiple Messages API, then in the alias I use $(querystring) to recover that sentence URL-encoded, as it’s required:

$(urlfetch https://vxrl.xyz/smm/$(query)?i=5000&d=1)

How to set up

  • through the chat:

    !addcom !commandName -a=_commandName $(eval ...)
    !addcom _commandName $(urlfetch https://vxrl.xyz/smm/$(query)?i=5000&d=1)
    
  • through the dashboard:

    • first command:
      Command: !commandName
      Message: $(eval ...)
      Alias: _commandName
    • second command:
      Command: _commandName
      Message: $(urlfetch https://vxrl.xyz/smm/$(query)?i=5000&d=1)
      Alias: leave empty

Thank you for taking the time to write in English, I appreciate it.

Thank you very much for helping me with my problem, I really didn’t know it could be done that way, you solved everything for me, excellent work, have a good night and thanks again.

Maybe I explained myself wrong but by any chance do you know how to make nightbot give an answer in different parts?

1 Like

Right, I was worried this might be an issue, you see $(querystring) encodes using encodeURIComponent(), which encodes the slash (/) as well, I thought the API would still work as intended, but turns out it’s not the case, so we want the slash to remain as is, for that we can use encodeURI() instead.

I’ve fixed the code in my answer above, both commands were edited.
I had time to test the fix, it works as intended now.

Oooh thank you very much for completely solving my problem and also giving you the time to correct the previous message and try it also, I really appreciate it very much and I hope you have a good day, see you soon!

1 Like

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