NightDev Community Forums

Shout-out last host

#1

hello, i was wondering if anyone has figured out how to make the !so command do a shout out for the last person that hosted the channel

#2

@alphasarmy

The following command setup should find the last channel that hosted you and give them a shout-out.

!addcom -cd=5 !so $(eval r=`$(urlfetch json https://tmi.twitch.tv/hosts?include_logins=1&target=$(channelid))`;try{a=JSON.parse(r);b=a.hosts;c=b[b.length-1].host_login;`Go check out ${c}'s channel at https://twitch.tv/${c}`;}catch(e){`Couldn't find a recent host!`;})
3 Likes
#3

hmm for some reason that command keeps pulling up a channel that i have never seen beforeā€¦

#4

Hm not much Nightbot can do about that, everyone can host your channel, the data is coming straight from Twitch.

#5

I edited the command response to allow you to filter out particular channel names.

!addcom -cd=5 !so $(eval r=`$(urlfetch json https://tmi.twitch.tv/hosts?include_logins=1&target=$(channelid))`;try{a=JSON.parse(r);b=a.hosts.filter(c=>![`CHANNEL1`,`CHANNEL2`].some(d=>c.host_login.toLowerCase()==d.toLowerCase()));z=b[b.length-1].host_login;`Go check out ${z}'s channel at https://twitch.tv/${z}`;}catch(e){`Couldn't find a recent host!`;})

Replace CHANNEL1 and CHANNEL2 with the channel names that you want to filter out. Note that you can add more names; just make sure each name is separated by commas and bounded by backticks as shown above.

closed #6

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