Use Nightbot variables in Pastebin

i’m try to make a filter on chat with “https://pastebin.com/raw/QNGztScQ”. But the code of :

$(urlfetch json https://pastebin.com/raw/QNGztScQ)

or

$(eval function F(){$(urlfetch json https://pastebin.com/raw/QNGztScQ)}F())

i’m not programer and y search for all forums but never found 1 good for make it. I want to change the code when i want but usual says problems like :
Nightbot: Invalid or unexpected token
///
Nightbot:missing ) after argument list

if any can help me for make this can use full pleas…

You can’t run nightbot variables through a pastebin like that one nightbot fetches the data it doesn’t look through it for variables again.

Additionally the command is short enough that it can just be added through chat or the nightbot dashboard without the need for urlfetch json.

Then how i make for put command like this of more than 500 characters (this one have less but in future the names of blockeds will be longer)

i know its an example i want to make 1 with more than 500 characters because i want make a bit more complex and more names.

Do all the urlfetchs and stuff outside the pastebin and then do the rest of the command in the pastebin.

1 Like

all are stuff of urlfetchs if u see the pastebin

What do you mean? You cant do the urlfetch from inside the pastebin.

1 Like

Hey @steelboost!

If you want to use Nightbot variables values inside a Pastebin, you need to call them before entering the Pastebin as Nightbot reads that code but doesn’t replace the variables, it’s linked to how JS works.

So for your code, here’s how to do it, call the $(urlfetch) and define $(user) outside of the paste:

$(eval r=`$(urlfetch json http://tmi.twitch.tv/group/user/$(channel)/chatters)`; u=`$(user)`; $(urlfetch https://pastebin.com/raw/QNGztScQ))

And inside your paste QNGztScQ, have the rest of the code:

try{c=JSON.parse(r).chatters;a=c.vips.concat(c.moderators,c.staff,c.admins,c.global_mods,c.viewers).filter(n=>![`${u}`,`Nightbot`,`aten`,`Kodiakbrujah`,`Ildelara`,`Connoted`,`Casinothanks`,`streamelements`].some(o=>n.toLowerCase()==o.toLowerCase()));a.length?a[Math.floor(Math.random()*a.length)]:`No chatters`}catch(e){`Couldn't fetch the list of chatters: ${e}: ${r}`.slice(0,400)}

Notice I replaced $(user) by ${u} since we defined the variable earlier.

1 Like

Wow amazing!! now… if not are so much ask this code was 1º step and the 2º step and don’t know why not work its this one ::

!give ༼ つ ◕_◕ ༽つ $(eval if('$(touser)'!='$(user)'){a=decodeURIComponent('$(querystring)').replace('$(touser)',' ');a.slice(1);a;}else{'$(eval r=`$(urlfetch json http://tmi.twitch.tv/group/user/$(channel)/chatters)`; u=`$(user)`; $(urlfetch https://pastebin.com/raw/QNGztScQ))';}) to $(touser)

I don’t know if are logic but i want him take 1 of that random users when not callin $(touser)

$(eval `$(2)`==`$(twitch $(touser))`!=`Unknown Twitch Channel`? '$(user) ha besado a $(touser) ' : '$(user) ha besado a $(eval r=`$(urlfetch json http://tmi.twitch.tv/group/user/$(channel)/chatters)`; u=`$(user)`; $(urlfetch https://pastebin.com/raw/QNGztScQ)) ')

this one don’t work … i’m realy starter in night bot and trying complex comands i know…

Yeah, that’s not how you want to go about it, following the same logic as before, put the test and the different responses inside the paste:

$(eval r=`$(urlfetch json http://tmi.twitch.tv/group/user/$(channel)/chatters)`; u=`$(user)`; t=`$(touser)`; $(urlfetch json https://pastebin.com/raw/QNGztScQ))

if(u==t){try{c=JSON.parse(r).chatters;a=c.vips.concat(c.moderators,c.staff,c.admins,c.global_mods,c.viewers).filter(n=>![`${u}`,`Nightbot`,`aten`,`Kodiakbrujah`,`Ildelara`,`Connoted`,`Casinothanks`,`streamelements`].some(o=>n.toLowerCase()==o.toLowerCase()));a.length?`༼ つ ◕_◕ ༽つ ${a[Math.floor(Math.random()*a.length)]}`:`No chatters`}catch(e){`Couldn't fetch the list of chatters: ${e}: ${r}`.slice(0,400)}}else{`༼ つ ◕_◕ ༽つ ${t}`}

I don’t understand what the second command is supposed to do, like the logic doesn’t make sense, but it seems fairly similar to the first one, so with my corrections you should be able to figure it out.

Learn JavaScript if you want to make complex commands. Here’s a resource to start: W3Schools, and later you might be interested by MDN, but it’s a more advanced documentation.

1 Like

give the same error

Nightbot

: Unexpected identifier

Add json in the second $(urlfetch).

God, thank you very much, you are my God. I’ve been searching and testing every day for three weeks. Thank you .

1 Like

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