Hi,
I'm trying to make a hug command that gives a specific user a special message and works for everyone else just as a normal hug command where you can either target a user or get a random one.
I managed to get the first part to work as well as the second but together they don't work.
When I want to get a random user I get an error message saying invalid channel. It works though if I target a user. Does anyone know why it doesn't work?
Is it because the else part is technically if else as well?
Like if there is a message use that if it’s empty use a random user. And if so how do I fix this?
This is the command I am using 🙂
js!addcom !hugtest $(eval if(`$(user)`.toLowerCase() == "kyram"){`Error`}else{"$(user) gives $(eval decodeURIComponent("$(querystring)")||"$(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel))") a warm and friendly hug paliHug fruitAww"})
Edit: I have tried redoing it with a Pastebin but i do not seem to do it right...
This time it gives me Unexpected token '{' as error message.
This is my command:
$(eval u="$(user)"; r="$(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel))"; q="$(query)"; $(urlfetch json https://pastebin.com/raw/YQJQ2YRt);)
and this is in my Pastebin:
if (${u}.toLowerCase() == "kyram") {var hugMessage = "${u} Error";} else if (${q} == "") {var hugMessage = "${u} gives ${r} a hug";} else {"${u} gives ${q} a hug";} hugMessage;