Can nightbot give a delayed response to a command?

Trying to make a randomized pizza command where you type !pizza and nightbot will draw from two pastebins, one for pizza style and another for toppings. (this part isnt the problem, I have this part done)

Right after the command is called I want nightbot to respond to the user with an order number or just a basic msg saying their pizzas in the oven or something (also not the problem)

question I have is this. Is there a way for nightbot to wait after giving the first response for like 2 mins or so, and then respond again with the randomized choices or is that no possible?

Hey @theshreddingmonkey!

Allow me to try to recap to see if I understood well:

User: !pizza
Nightbot: [random pizza with random toppings]
Nightbot: Your pizza is in the oven and will be ready in 2 minutes
... — 2 minutes later —
Nightbot: Your [random pizza with random toppings] is ready, User!

If that’s what you’re looking for, then it’s not possible, there’s no way for Nightbot to remember the value of a variable once the command ran, and in case of the multiple message API, it uses Nightbot API to send extra messages, the command has finished running the first time Nightbot responds.

What I can suggest is giving each user an “order number,” and then you can use bits of this code I wrote before:

ok Ill take a look at that and see what I can workout. for the meantime I set it to just draw to random toppings from a pastebin and produce it instantly. only issue is, the command to draw from the pastebin takes up lots of room and uses majority of the the allowed command text so I dont have room currently to add to the command.
Ill paste the command im currently using.

$(user), your $(eval phrases = decodeURIComponent("$(querystring $(urlfetch json").split("|"); phrases[Math.floor(Math.random() * phrases.length)]) and $(eval phrases = decodeURIComponent("$(querystring $(urlfetch json").split("|"); phrases[Math.floor(Math.random() * phrases.length)]) pizza is ready

im unsure if theres a way to pull more than one item from the pastebin without having to have that string repeated in the command.

Well, you could have everything in a big Pastebin, that’s not an issue, but your current code can definitely be improved: you don’t need to call the same Pastebin twice (it’ll make preventing duplicate picks easier too), and there’s a lot of unnecessary code as well:

$(eval p = '$(urlfetch json'.split('|'); r = () => p.splice(Math.floor(Math.random() * p.length), 1); `$(user) your ${r()} and ${r()} pizza is ready!`)
1 Like

Thank you very much for your help Emily, you are very kind


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