Custom Nightbot command

Hello, I’m trying to make a command where it chooses a random viewer on the chat, but I tried to filter the bots out and for some reason the broadcaster won’t get picked by the command. Could anyone help me out?

$(eval r=$(urlfetch json$(channel)/chatters);try{c=JSON.parse(r).chatters;a=c.moderators.concat(c.staff,c.admins,c.global_mods,c.viewers).filter(n=>![“streamelements”,“soundalerts”,“lolrankbot”,“creatisbot”,“nightbot”,“nome”].some(o=>n.toLowerCase()==o.toLowerCase()));a.length>0?a[Math.floor(Math.random()*a.length)]:No chatters!}catch(e){Error: ${e.message}: ${r}.substr(0,400)})

Hi, I’m using this code found here and it works as intended for me :slight_smile: I myself cant really read code so i cant edit yours but hopefully i still helped in some way?

That’s just because the code you have doesn’t include the broadcaster from the json text I edited it below to include the broadcaster in the concatenation.

$(eval r=`$(urlfetch json$(channel)/chatters)`;try{c=JSON.parse(r).chatters;a=c.moderators.concat(c.staff,c.admins,c.global_mods,c.viewers,c.broadcaster).filter(n=>![`streamelements`,`soundalerts`,`lolrankbot`,`creatisbot`,`nightbot`,`nome`].some(o=>n.toLowerCase()==o.toLowerCase()));a.length>0?a[Math.floor(Math.random()*a.length)]:`No chatters!`}catch(e){`Error: ${e.message}: ${r}`.substr(0,400)})
1 Like

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