Problem with using $(eval)

Halo everyone,

I am facing a problem when I want to apply javascript on a command, can anyone help with this? Thanks!

I am making a custom command on my channel “!Do You love me?”.

And I want nightbot to answer randomly so as I plan to use javascript as follow:

ans = new Array(4);
ans[0] = “No, I dont love you.” ;
ans[1] = “Yes, I love you too” ;
ans[2] = “Leave me alone” ;
ans[3] = “Get away from me!” ;
index = Math.floor(Math.random() * ans.length);

But Nightbot answer “document is not defined” when I type the command “!Do You love me?”

Nightbot doesn’t have any document variable. Nightbot’s reply is simply the last evaluated expression.

$(eval ans=["No, I dont love you.","Yes, I love you too","Leave me alone","Get away from me!"];ans[Math.floor(Math.random()*ans.length)])

Many Thanks for your help! Problem solved, thanksssss!!!

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