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…
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:
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.
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.