The eval variable can't run

$(eval a=$(urlfetch json https://pastebin.com/raw/CG2QrDeS);a[Math.floor(Math.random()*a.length)])

The variable can’t run, what is the reason?

The eval in this command code works fine.

$(eval a=$(urlfetch json https://pastebin.com/raw/dnJUHxZU);a[Math.floor(Math.random()*a.length)])

But Nightbot will literally output variables that have been pulled by a urlfetch instead of executing them properly.

1 Like

https://pastebin.com/raw/CG2QrDeS Is there a way to make the variables inside appear randomly and execute? :sob:

This is your Pastebin text:

[`!deduct money $(user) -10 ,$(twitch $(user) "{{displayName}}" ) Travel around the world for a week.`,`!get money $(user) 10 ,$(twitch $(user) "{{displayName}}" ) found some money on the ground.`]

Edit it to this:

[`!deduct money -USER -10 , -DISPLAY Travel around the world for a week.`,`!get money -USER 10 , -DISPLAY found some money on the ground.`]

If you want to add more responses, remember to type -USER for the username and -DISPLAY for the display name.


New command code:

$(eval a=$(urlfetch json https://pastebin.com/raw/CG2QrDeS);a[Math.floor(Math.random()*a.length)].replace(/-USER/g,`$(user)`).replace(/-DISPLAY/,`$(twitch $(user) "{{displayName}}")`).slice(0,400))
1 Like

Thank you very much!

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