is it possible to make a global variable out of the message in a command? trying to make a link chain
i would put in !editlink www.soandso.com
and i would like to make it so that www.soandso.com became a global variable so that i can use it to edit these commands
!command edit !link “here i want the variable so that it becomes what i wrote in !editlink”
!command edit whats “here i want the variable so that it becomes what i wrote in !editlink”
!command edit join “here i want the variable so that it becomes what i wrote in !editlink”
Global variables are not possible to set up natively in Nightbot, but a workaround exists using ehsan’s quote API.
Click this link. It will generate three links and two tokens, a public token (8 characters long) and a private token (16 characters long). The public token is located within the first generated link. The private token is located within both the second and third generated links. The tokens are found after token= and before &data=$(querystring)Copy them down and keep them somewhere safe!
Below I have set up !editlink (mod-only) which stores the user input in the “global variable”. New input will overwrite the previously stored input. Replace PRIVATE_TOKEN with your private token.
!addcom -ul=mod !editlink $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(querystring))`;`The global variable is now set to "${decodeURIComponent(`$(querystring)`)}"`)
To set the global variable, type:
!editlink [input]
The following will then be the “global variable”. Replace PUBLIC_TOKEN with your public token:
@denniskarbonHide your tokens! If you share them, anyone can edit your lists.
And I would suggest:
!addcom -ul=mod !editlink $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(querystring))`;`The global variable is now set to "${decodeURIComponent(`$(querystring)`)}"`)
I highly recommend to add this command through the dashboard, so get rid of !addcom -ul=mod !editlink, so you don’t display your PRIVATE_TOKEN in chat.
There’s a small change, it makes a big difference.
And I don’t know why it wouldn’t work, the link with your token works, so it should work. Did you put only the $(urlfetch)? If no, would you mind copy/pasting your message here, so we can have a look at it, but hide your tokens.