Variable Answers

Hey, I´m really new to doing bots.
Now, I´ve started with the Nightbot for my Discord-Server and Livestream.
So, here my question:
I tried to have variable answers for one command.
I tried it with $(number), but it doesn´t work.
Maybe you know a way to do it. :slight_smile:
Sorry,if it´s a stupid question. I just don´t know how to do it.

@Rocky712 Click here to read up on the list of existing variables:

https://docs.nightbot.tv/commands/variables

There isn’t any $(number) command variable. Do you perhaps need to use the argument variables $(1), $(2), $(3)… $(9)? If not, you’ll have to be a bit more specific. Is this variable supposed to be from the user’s input which can be obtained via $(touser), $(query), and $(1)? Is your command supposed to manipulate some of that input data which can be done with JavaScript in the form of $(eval)?

I have looked on this page before. I was on the “more infomation” page of “argument” and there I found the $(number). ( https://docs.nightbot.tv/commands/variables/arguments )
I want to have one command with different answers I have choosen myself and the bot should take one of the answers randomly.

Example:
!weather
First Answer: It´s cloudy.
Second Answer: It´s sunny outside.
Third Answer:…
and etc.

I hope I could explain it to you. I have no really knowledge. :confused:

If you’re looking for a list of responses the bot chooses from at random, I suggest using $(eval).

Let’s say you’re making a command called !weather. The possible responses are:

“It’s sunny outside.”
“It is cloudy.”
“There is a slight drizzle.”
“It’s raining cats and dogs.”
“A tornado is on the horizon. A storm is coming…”

To add this !weather command:

!addcom -cd=5 !weather $(eval a=["It's sunny outside.","It is cloudy.","There is a slight drizzle.","It's raining cats and dogs.","A tornado can be seen on the horizon. A storm is coming..."];a[Math.floor(Math.random()*a.length)])

Thank you for your help! It works. :slight_smile:

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