A command that implements other commands?

Sorry if that sounds confusing, I’m a complete noob to this and just trying to figure out a way around the character limit when it comes to the 8-ball type response commands. I already figured out how to use pastebin for returning a longer list of different responses, but the problem with that is in some of those responses I want to put like $(user) or $(touser), but pastebin just copy and pastes the answers (go figure lol) and the will output exactly this “slapped $(touser) with a wet noodle”.

So then I thought, “well is it possible for a command to activate another command?” Something like this

!addcom !slap $(user) $(eval const responses = [!love, !hate]; responses[Math.floor(Math.random() * responses.length)]:wink:

and then !love and !hate would have different lists of answers but in the same form as above using $(user) and $(touser) in the responses. (and also I could just set !love !hate to be mod only commands so they couldn’t be used, but nightbot is a mod so it shouldn’t have a problem when it executes the main command !slap command maybe…?)

So is there some way to do this? or if you have a better suggestion, I’m all ears! Thank you! <3

Well to answer you first question set variables like $(user) $(1) $(touser) equal to some letter or word
Ex.

  • user="$(user)"
  • touser="$(touser)"
  • arg1="$(1)"

It will look like this when adding the command:

$(eval user="$(user)";touser="$(touser)";responses=$(urlfetch json https://pastebin.com/raw/xxxxxx);responses[Math.floor(Math.random()*responses.length)])

Examples of how to use:
“Wow, “+user+” just slapped “+touser+”!!!”
user+", loves "+touser


To answer your second question simply no, Nightbot can only activate other commands if an alias is set.


And lastly couldn’t you just combine the love and hate commands together into one separate pastebin for one big slap command?

1 Like

Ok so on the pastebin I would write 1 line as:

  1. did not slap +touser+ because slapping is wrong,

  2. “did not slap “+touser+” because slapping is wrong”,

  3. did not slap touser because slapping is wrong,

Thanks for your help!

You would write it as number 2 just make sure you use the right quotes though I’m assuming you already know that as you have a love and hate command.

1 Like

If I don’t use the quotes in the command, do i need to use them in the pastebin? for example

$(eval user=$(user);touser=$(touser);responses=$(
pastebin: hugged +touser+ because +user+ is in love with them,

instead of

$(eval user="$(user)";touser="$(touser)";responses=$(
pastebin: hugged “+touser+” because “+user+” is in love with them,

You need to use quotes so it recognizes it as a string, so yes. Otherwise you will get an error. If your splitting the pastebin into an array in the eval you will have to change that to get this to execute properly. (By making it into and array from the start) Let me know if any issues arise.

Also,

pastebin: hugged “+touser+” because “+user+” is in love with them,

would be

pastebin: "hugged "+touser+" because "+user+" is in love with them"

Difference being the quotes at the start and end of each part of the array.

1 Like

Ok so here’s what I put:

!editcom !slap $(eval user="$(user)";touser="$(touser)";responses=$(urlfetch json PASTEBIN);responses[Math.floor(Math.random()*responses.length)])

(PASTEBIN is replaced with the proper url, ZvVsTuMU)

and when I do it, nightbot just returns random letters of the alphabet, no matter if I put !slap Mark or just !slap

This is most likely because it’s not a proper array can you link the pastebin an I’ll tell how how it should look.

It should be in this format

["Message "+user+" 1",
"Message "+touser+" 2",
"Message 3"]

Commas separate each message. And you should only have “[“ at the very beginning and “]” at the very end.

1 Like

I can’t put a link in the reply, but basically https:// pastebin .com/ZvVsTuMU

I checked out the link and the only thing you should have to change is adding [ and ] at the begging and end. Like this response if it works :heart:

1 Like

At the beginning and end of each line? Sorry I’m confused :sweat_smile:

So in the pastebin like this:
[ and ]“slapped “+touser+” with a restraining order”,[ and ]
[ and ]“hugged “+touser+” because “+user+” is in love with them”,[ and ]

Or like this:
[ and ]“slapped “+touser+” with a restraining order”,
“blew “+touser+” a kiss”,
“hugged “+touser+” because “+user+” is in love with them”,[ and ]

Thanks again for your help.

Just a
[
at the very beginning and a
]
at the very end

1 Like

Omg I misread that message before. It works LOL this is so cool!! Thank you thank you thank you. You’re the best!!!

1 Like

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