syntax to urlfetch a variable

Ok thanks for clarifying, let me just yoink some of Emily’s code from this recent topic.

You will need to post some code to pastebin, since the text is to long for a Nightbot command.
Pastebin code, where you can edit the responses:

try
{
	c = JSON.parse(r).chatters;
	a = c.vips.concat(c.moderators,c.staff,c.admins,c.global_mods,c.viewers)
		.map((a) => ({sort: Math.random(), value: a}))
  		.sort((a, b) => a.sort - b.sort)
  		.map((a) => a.value);

	if(a.length >= 3)
	{
		`${a[0]} wants to f*** ${a[1]}, marry ${a[2]}, kill ${a[3]}`
	}
	else
	{
		`Not enough chatters`
	}
}
catch(e)
{
	`Couldn't fetch the list of chatters: ${e}: ${r}`.slice(0,400)
}

Then add a command to Nightbot like this, where you replace the XXXX pastebin ID:

!commands add !something $(eval r=`$(urlfetch json http://tmi.twitch.tv/group/user/$(channel)/chatters)`; $(urlfetch json https://pastebin.com/raw/XXXX))

Not sure how big the channel is, because I dont know if it will work fluenty in big channels, but try it out. :slight_smile:

2 Likes