Hi,
I am just starting out and need help with conditional statements. (I setup the following to run tests on conditional statements in Nightbot commands)
I managed to get this 1st block of code to function properly
(I just changed MYUSERNAME between tests to either match or not match my own username):
!editcom !test $(eval var a = "$(user)";
if (a === "MYUSERNAME")
{"Correct User";}
else
{"Wrong User";}
)
However, when I then tried this version, using requests to the Custom Quote API
(I replaced TOKEN with my actual token):
!editcom !test $(eval var a = "$(user)";
if (a === "MYUSERNAME")
{
($(urlfetch http://twitch.center/customapi/addquote?token=TOKEN&data=$(querystring)); )
("Correct User");
}
else
{
($(urlfetch http://twitch.center/customapi/addquote?token=TOKEN&data=Wrong); )
("Wrong User");
}
)
... the result is that both urlfetch requests are performed
(2 entries are made with the string I enter and "Wrong")
as well as Nightbot returning
Right-hand side of 'instanceof' is not an object
instead of "Correct User" or "Wrong User".
My 1st question is why are both parts of the If/Else getting ran?
2nd question is why is Nightbot outputting this error rather than one of the text outputs?
Thanks.