Random multiple chat users command

hi i want to make a command that grabs 3 users in twitch chat at the same time - for example the way that nightbot would reply back would be -

$(user), A -*chat user#1, B -*chat user#2, C -*chat user#3

not sure if its possbile to select multiple users for a command or how to write out so any help would be great thanks

Hey @blockws!

I assume you want the 3 users to be picked at random, so we’ll borrow code from this command.

$(eval r=`$(urlfetch json http://tmi.twitch.tv/group/user/$(channel)/chatters)`;try{c=JSON.parse(r).chatters;a=c.vips.concat(c.moderators,c.staff,c.admins,c.global_mods,c.viewers).filter(n=>![`$(user)`,`Nightbot`,`UnwantedUser3`].some(o=>n.toLowerCase()==o.toLowerCase()));t=[];if(a.length<3) throw `not enough chatters in chat`;for(i=0;i<3;i++){t.push(a.splice(Math.floor(Math.random()*a.length),1))}`$(user), A - ${t[0]}, B - ${t[1]}, C - ${t[2]}`}catch(e){`Error: ${e}`.slice(0,400)})

Feel free to replace UnwantedUser3 with the username of someone you don’t want Nightbot to pick, for example the streamer or another bot, you can have more than 3 UnwantedUsers, just make sure the command code doesn’t go above 500 characters and to follow the proper syntax.


1 Like

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