Need help with the nightbot command

i need 1 message for streamer and 3 random messages for any user
$(eval if("$(query)"==“streamer”||"$(query)"=="@streamer" || “$(query)”=="@Streamer"){"$(query) message $(user):japanese_goblin:"}else{var u=["$(user) msg1 $(query) “,”$(user) msg2 $(query)","$(user) msg3 $(query)"];u[Math.floor(Math.random() * sayings.length)]})
how to write it correctly

Hey @melochhhh!

It seems to me that apart from the wrong quotes “” surrounding the third $(query) and the first comma in your list of random messages, it should work. JavaScript only supports '"`, pay attention to your quotes when you write code. Wrong quotes, and the fact that sayings is no declared, you should have used u there, you could also have replaced u.length by 3 since you know the length of the array and that it’s fixed.

In the meantime, here’s a fix with improvements to make it more efficient:

$(eval q=`$(query)`.replace(`@`,``).toLowerCase(); r=[`RANDOM_MESSAGE_1`,`RANDOM_MESSAGE_2`,`RANDOM_MESSAGE_3`]; q==`$(channel)`?r=`STREAMER_MESSAGE`:r=r[Math.floor(Math.random()*r.length)]; `$(user) ${r} ${q}`)
2 Likes

big thanks <33333333333333

1 Like

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