Why can i only use variable $(count) inside eval?

I’m trying use any others variables like ${touser} and ${number} but I’m getting “undefined” error.

This command is working fine
!commands edit !test $(eval count = $(count); count;)

And this is not working
!commands edit !test $(eval touser = $(touser); touser;)

return “is not defined”

Ok, i found the problem. Is just use variable inside a string, there is no sense but works.

!commands edit !test $(eval touser = “$(touser)”; touser;)

Hey @dunasz!

It makes sense to assign strings to your touser variable as $(touser) is a string Nightbot simply replaces with the correct value, so you have to specify it. In your first case, you were assigning the variable $(touser), which was not defined, to touser.
For $(count) it works without the quotation marks because it’s an integer and they don’t need to be stored as strings to work properly.

1 Like

Really, now it makes sense. Thank you for explanation!

1 Like

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