I want to print an output within the command line

Hello, relatively new user here. I have a very basic understanding of JavaScript, as I took a class for it in high school. I apologize if my jargon isnt very up to code.
I’ve been using NightBot recently, and I was wondering if it was possible to carry over a variable after it’s been defined within the command line?
For example, I have this code

$(eval const responses=[‘response 1’, ‘Response 2’, ‘Response 3’, ‘Response 4’]; responses[Math.floor(Math.random() * responses.length)]:wink:

And it works to randomly select one of the responses and output it into chat.
The end message being “Don’t forget to check out (response) on Twitch!”

Is there a way I could take (response), and make it output in the same command, so I could have it output fully as:
“Don’t forget to check out (response) on Twitch

Sure, just expand the eval to output more text.

$(eval const responses=['response1', 'Response2', 'Response3', 'Response4']; const res = responses[Math.floor(Math.random() * responses.length)]; `Don't forget to check out ${res} on Twitch.tv/${res}`)

Oh, thank you! Thank you so much! I tried different things but couldn’t quite figure it out. It works like a dream, now!

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