syntax to urlfetch a variable

Please if anyone knows is it possible to use a url as a variable with $(urlfetch), specifically, the url for getting a random user, like:

$(eval url1=$(channel); $(urlfetch url1)

I want to do this so that I can call urlfetch 4 times in a single command without using the full length url each time - to stay below the max character limit in Twitch chat when adding the command.

Hiya, what kind of command would you like to make? Think there is better solutions to get multiple users from your viewerlist if you directly get them from Twitch with one request, instead of calling this API multiple times.

Howdy, like, a twist on the game of: one friend names 3 celebrities or other friends then a second friend hypothetically decides which one they’d marry, which one they’d kill, and which one they’d …sleep with.

so like: "random user" wants to f*** "random user", marry "random user", kill "random user"

current version of the command looks like this – which works, but I wanted to make a more complicated version and then ran into the character limit issues:

!editcom !FMK @$(urlfetch$(channel)) wants to F**K @$(urlfetch$(channel)), marry @$(urlfetch$(channel)), and KILL @$(urlfetch$(channel))

Yes, please though, if there’s a way to get multiple users from the viewerlist with one request please let me know (I should probably have tried researching that angle first).

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:

	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]}`
		`Not enough chatters`
	`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$(channel)/chatters)`; $(urlfetch json

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:


That is awesome thank you.

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