Commands for tagging random or selected viewers

Looking for a code that allows a command to tag both a random viewer or @viewer. Been looking all over the internet but no luck

Hey @mizzzarie!

It’s weird because using the search bar I easily found the answer.

1 Like

That code for the slap command worked for a slap but it isnt working in the way im trying to make it work. Every @ user or random user codes used for like slap commands and such i have found didnt work in the way im trying to use it. We have a gift command that gives random viewers a gift. But we want it to be able to give gifts randomly but also to a person that is tagged.
We also have a command called !love that says the Streamer loves the viewer that did the command a percentage. But i used that slap coding to try to make it a tagged or the streamer if a @ wasnt used. But the code never worked properly in any of those commands. But worked find with the slap command.

Ok so if I understand this is what you want?
!gift

Gift given to $(touser) and $(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel))

!love

$(eval `$(touser)`!=`$(user)`?`$(touser)`:`$(channel)`) loves $(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel)) $(eval Math.floor(Math.random()*101))% <3
1 Like

very close to what im looking for. At the moment we have this gift command
!addcom !gifts $(user) gave (random viewer) a gift of (random gift code i found online)
how it is now it only allows me to give gifts to random users. I want to keep that but also make it so i can tag a specific viewer and give them a gift instead

and the !love command you gave me almost worked but in keeps saying invalid channel even tho i put the channel name i mod for in the channel area

sorry i tried to add the exact command im using so you can see exactly what im talking about but im new to this and it said i couldnt post it because it had a link.

That’s what the commands I linked are useful for, to give you a guide on how to do this.

$(eval '$(query)'?t='$(query)':t='$(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel))'; `$(user) gave ${t} a gift!`)

It’ll be difficult to link that to the random code you found online given you haven’t provided it to us.

There’s no need to replace the text in $(channel), leave it as is, it’s a Nightbot variable that automatically does the job for you. If you needed to modify anything we would have said so.


If you want more help, please give more details as to how you want the commands to work, you need to be specific.

That was a good start, and that should have been there from the start, but it’s still far from being perfect, instead of (random viewer) you should have said (target or random viewer) for example, to help us understand you better.

1 Like

I would love to post the exact command we currently have so you can see exactly what I want to modify but it wont allow me to add it because it says links isn’t allowed. If I was told how to do that I gladly would.

You can share the code by either putting it between three backticks ` on each side, by putting it on a new line and preceded by an empty line and 4 spaces, or using the code formatting button (the 6th one), that should prevent the link flag.

```code```
empty line
    code

Thank you. This is the command i currently use. The random gift fyrewire pastebin i found online.
!addcom !gifts $(user) gave $(urlfetch https://decapi.me/twitch/random_user/banityttv) $(urlfetch https://api.thefyrewire.com/twitch/pastebin/6QNZhBst?return=$(urlfetch http://2g.be/twitch/randomnumber.php?start=1&end=2)&separator=and)
how the command is now it will give a gift to a random viewer of the stream. I was trying to find a way to keep it random but also allow you to go !gifts @someone and it would give the gift to that person instead.

the love command we currently have is !addcom !love $(user) loves $(eval `$(touser)`!=`$(user)`?`$(touser)`:`$(channel)`) $(eval Math.floor(Math.random()*101))%
as it is now it says “user loves the streamer percentage”. But im trying to make it so if i just typed in !love it would stay like that but if i put in !love @viewer i could make it say “User loves tagged user percentage” if that is possible i have a few commands i would like to do that way

Okay, so here’s how to merge your current !gift command with the one we wrote here:

$(eval '$(query)'?t='$(query)':t='$(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel))'; r=Math.ceil(Math.random()*2); g='$(urlfetch https://api.thefyrewire.com/twitch/pastebin/6QNZhBst?return=2&separator=|)'.split('|'); `$(user) gave ${t} a gift of ${r==1?g[0]:g.join('and')}!`)

For your love command, it very similar to the first !gift command I wrote you:

$(eval '$(query)'?t='$(query)':t='$(channel)'; r=Math.floor(Math.random()*101); `$(user) loves ${t} at ${r}%!`)

With that you should be able to write the other similar commands you want to behave this way.
Basically, to choose between a target or the channel, use:

'$(query)'?t='$(query)':t='$(channel)'

And to choose between a target and a random user, use:

'$(query)'?t='$(query)':t='$(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel))'

I recommend you give it a good try yourself, and only if you really can’t figure it out ask for more help, but with those two you should have enough examples on how to do what you’re looking for. I recommend you read the documentation as well.

We’re not supposed to write everyone’s commands.

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