Nigthbot calling command

Hi, I want to create Randomizer with sub randomizer, using:

!question → $(eval const responses = [’!Answer1’, ‘!Answer2’, ‘!Answer3’, …]; responses[Math.floor(Math.random() * responses.length)]; )

!Answer1 → $(eval const responses = [‘ExampleA’, ‘ExampleB’, ‘ExampleC’, …]; responses[Math.floor(Math.random() * responses.length)]; )

!Answer2 → $(eval const responses = [‘ExampleD’, ‘ExampleE’, ‘ExampleF’, …]; responses[Math.floor(Math.random() * responses.length)]; )

!Answer3 → $(eval const responses = [‘ExampleG’, ‘ExampleH’, ‘ExampleI’, …]; responses[Math.floor(Math.random() * responses.length)]; )

and when Nightbot writes !AnswerX nothing happens

This is for making sub randomizer, to enter a lot of random responses to a question, making a tree

Nightbot can’t trigger its own commands by typing them in the chat it would have to be through the alias. What your trying to do isn’t really necessary you could do it all in one command if you use pastebin from what I’m understanding.

You’d have to recode it, but it is possible for Nightbot to trigger a command.

The Nightbot types correctly the word, but command does not work. If I type the command it works. The userlevel used to try is anyone.

What Potato said above is accurate. With stuff like this in the past I’ve used another bot to trigger nightbot.

Hey @JoseanR!

As you’ve been told before, Nightbot can’t be triggered by commands in its own messages as it ignores them, you can use an alias command to trigger an extra command, but that’s it, as @potatoeaterlove said, your best bet here seems to be using a Pastebin, or you can also use a multiple message API.

I´m using Pastebin Now, but I don´t know what url from pastebin I´ve to put on the command
My command is:
$(eval a=$urlfetch json PASTEBINURL) a[Math.floor(Math.random()*a.lenght)])
but it doesn´t work.
Inside the Pastebin doc, the items are between (’) and separated with (,)
I don´t know if it´s the command, the URL or both
Thanks a lot

Finally I’ve succeeded!!!

I had some errors in the code without square brackets ( [ ] ) on the pastebin, and the link I had to put on the code was the raw.

The final command is:
$(eval r= $(urlfetch json https://pastebin.com/raw/XXXXXX); r[Math.floor(Math.random() * r.length)] ; )

And the Pastebin is:
[
‘Example1’,
‘Example2’,
‘Example3’
]
^—That square brackets were missing

Thanks to all!!

1 Like

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