Hi, I’m trying to create a command that will allow me to change the daily “Coffee Concoction” without editing the command in nightbot every stream. I was thinking I could have it connect to a pastebin, but I’m not quite sure how to do that, and also not sure on how to make it cycle between streams. Is this possible?
Creating an Editable Command
6 replies
Hi,
You can get the day using Nightbot’s variable Time, and then get the data from pastebin using json and query the day.
In a very basic way could be like:
javascript$(eval day=`$(time YOURTIMEZONE "dddd")`; data=$(urlfetch json YOUR_RAW_PASTEBIN_URL); `${day}'s special coffee is: `+data[day])
The Pastebin formatted as:
json{"Monday": "Mocaccino","Tuesday": "Latte","Wednesday": "Americano","Thursday": "Cappuccino","Friday": "Espresso","Saturday": "Machiato","Sunday": "Affogato"}
Command can be more elaborated to validate the query is not null/empty.
But overall in this way you don’t need to modify your command every day.
Hope this help. :upside_down_face:
I attempted to make this work, but am getting an error when testing. Here is my command (the forum wouldn’t allow me to post the whole pastebin link together so there are spaces here that are not in the command)
$(eval day=$(time US/Central "dddd"); data=$(urlfetch json https:// pastebin .com/XbFF9Gvi); \`🔮 The Cauldron bubbles… tonight’s special is:’ +data\[day\])and here is the error I keep getting
Unexpected token ‘<’ \[:1:22\]
I’ve played around with the command a bit but have been unable to make it work 😕
Hi,
I checked your file, end each line of key and values in the pastebin with a comma instead of semicolon, the last entry should not have a comma.
For the command make sure the string start and end with the same symbol, and use the raw link of the pastebin, otherwise will give you an error.
javascript$(eval day=`$(time US/Central "dddd")`; data=$(urlfetch json https://pastebin.com/raw/XbFF9Gvi); `🔮 The Cauldron bubbles… tonight's special is: `+data[day])
Didn't find your answer? The community is on Discord.
Ask on Discord