Is there a mechanism for session variables in eval?

Hi, does Nightbot have any kind of mechanism to remember session variables in eval commands, or even its own native implementation outside of eval?

For example if i were to assign a random number of 1 to 10 to a user when they call a command !random, what i’d wanna do is store it, so that when they do it a second time, i can be like “your number is already 7” instead of generating a new one for them.

Nightbot doesn’t keep track of information like this by itself. You could use an alias of !editcom to record a random number or use ehsankia’s quote custom API to record your random numbers: [CustomAPI] Quote system

Sorry, can you elaborate what you mean by this?

Two commands. One displays text, one uses !editcom to change the text of the former:

!addcom -cd=5 !currentnumber Your current number is:

!addcom !randomnumber -a=!editcom !currentnumber Your current number is: $(eval Math.ceil(Math.random()*10))

Whenever you run !randomnumber, it will generate a random number from 1 to 10 which it will use to edit the response of !currentnumber

i don’t see how this would assign it to any specific user? this would assign the number to the “entire chat” so to say…

I suggest using the quote system api to store values for individual users.

yea okay, that one will probably do the trick, i’ll give it a go, thanks.

1 Like

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