Personalized Greeting Command

Hello, I’m trying to set up a personalized greeting code for a friends channel but I’m having some difficulties. I’m trying to get the basic code working before I get it super personalized but I cant even get it working, I keep getting “Unexpected String”. I copied the basic code off of a website that had a few obvious errors in the original code, so I fixed up what I could, but my knowledge in javascript is very limited, and google has failed me.

What I have is:

$(eval a=$“(user)” $urlfetch https://pastebin.com/raw/xxxx))

its supposed to read a pastebin file with the following (removing specific twitch usernames):

if (a == “UserOne”) {“Everyone say hi to UserOne!”;}
else if (a == “UserTwo”) {“Welcome! Everyone say hi to UserTwo”;}
else {“Hello welcome to the stream!”}

Hey @ruzukimay!

Knowing Javascript helps, but so does following the Nightbot variables syntax, which you can see in the documentation.

With that in mind, here’s how your command should look like, and you don’t need a Pastebin if you create a special greeting message for one or two person:

$(eval u='$(user)'; if(u==='USER_ONE'){'GREETING_MESSAGE_ONE'} if(u==='USER_TWO'){'GREETING_MESSAGE_TWO'} else{'GENERAL_GREETING_MESSAGE'})

If you need to mention the user in the greeting message, use $(user), you’ll likely save some characters.

If you need to use your Pastebin because there are many user-specific greeting messages, the code inside it should work. As I said previously, your main issue is that you don’t use the proper syntax for Nightbot variables:

$(eval a="$(user)"; $(urlfetch json https://pastebin.com/raw/XXXXXXXX))

Thanks! I fixed up the command.

I do want to go with the pastebin route, she intends to make a number of greetings, I’m just starting with the three to see if I can get the code working first before I complicate and personalize it…

Now it gives an error saying “Invalid Token If”. So it seems I do have something wrong in the pastebin, but I cant figure out what… I followed the if else tutorial on w3schools and my code is very similar so not seeing any obvious errors.

Oh, it might be because you used the wrong quotation marks: “”, instead of "" or ''.
That’s the only issue I can notice in your first message, otherwise I can’t say without looking at the Pastebin.

Hi, made sure it had the correct quotations and still getting “Invalid Token If”

I don’t mind sharing the link: = pastebin .com/ yHy9FEfm

It works fine when I test it, make sure the command is written properly as well, see my first reply.

Seems I was missing a semicolon in the original command, not sure how I missed that since I thought I had just copied and pasted it… Works now, thanks so much!

No worries, it happens, glad it works now!

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