Different responses to the command

Asked Nov 21, 2020·22 replies·Last activity 5 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hi guys, I have a question
Can I make the bot react differently to the command? So to speak, different answers to 1 command

I hope I could explain what I need

For instance:
command "yes"
the bot will answer "no" or answer "yes" or answer "maybe"

Depending on the answer options
If this can be done, please tell us in detail how?

22 replies

@Sandy Goat Welcome to the community. Try this:

!addcom -cd=5 !COMMAND_NAME $(eval const responses = [`yes`, `no`, `maybe`]; responses[Math.floor(Math.random() * responses.length)];)

Your command is similar to !8ball
Regards

And if I want to add some long answers, can I do it somehow?

Can I somehow add many long text answer choices? For example, quotes from famous people

Yes you can. Just note that there is a character limit. There is a way around it if you need a lot of responses though.

yes, I would like to get around this limitation
But how can this be done?

You’ll want to use pastebin you’ll write out a pastebin like this:

Qoute1:
Qoute2:
Qoute3

Make sure the ‘:’ is in between all the responses

Can you describe this in more detail? And throw off an example

@Sandy Goat Well, you can use mine quotes command.

!addcom -cd=5 !quotes $(eval a = $(urlfetch json https://pastebin.com/raw/CQ6sdh4r); a[Math.floor(Math.random() * a.length)];)

Regards

So basically you’ll want to creat an account on pastebin and write out the responses like I said. Here’s an example https://pastebin.com/raw/6AfagFQq

Then the command will look like this:

$(eval a=`$(urfletch json Raw_Pastebin_Link)`.split(`SEPARATOR`);a[Math.floor(Math.random()*a.length)])

The “SEPARATOR” is whatever you use to separate the responses it should be something like , ; : | ~ or - just things that wont appear in the qoutes. The raw pastebin link is the link to your pastebin file.

I’d recommend just putting the answers in the way I showed as it is simpler to do. But both work just the way you format the command is different depending on which you use.

Should I replace the word "SEPARATOR" with the ending character or leave it as it is?

.split(`SEPARATOR`); or .split(`|`);

Thank you, it was your method that worked for me ❤️

@Sandy Goat I will add more quotes in the future. Regards

Edit: Quotes*

how to make the bot respond normally to a person?

Screenshot_1.png

Hey @Sandy Goat!

That should work... 🤔

Is the command just this text or is it an $(eval) or something else?
Do you mind posting the command text, not a screenshot? That would help us help you.

I used this command with several answer options, but for some reason the bot did not mention the person who called it
$(eval a = $(urlfetch json https://pastebin.com/raw/7FGZVsy3); a[Math.floor(Math.random() * a.length)];)

Nightbot doesn't read variables when called from a Pastebin, because it reads and replaces the variables once, so it just calls your Pastebin and that's it. What you have to do is define $(user) outside of the Pastebin, and then you can refer it inside and JavaScript will do the job. So your command would go like this:

$(eval u=`$(user)`; a=$(urlfetch json https://pastebin.com/raw/7FGZVsy3); a[Math.floor(Math.random()*a.length)];)

And then in the Pastebin replace every instance of $(user) with ${u}.

Did I understand correctly?
Do I need to replace $(user) with ${u} in Pasterbin?

Yes that is all you have to do as long as it’s inside of ``

Didn't find your answer? The community is on Discord.

Ask on Discord