Trying to use an $(eval) command to randomly pick a URL from a pastebin to use as the URL for another $(eval) command. I thought the limit was 2 evals in a nest, so I figured this would work, but getting ‘Unexpected identifier’.
Basic idea is to just have a list of rss2json links with different news outlets so the command randomly outputs news descriptions. There’s probably a better way of doing this, but I’m still not sure why this doesn’t work.
You need to make a command which return link which then can be used by alias command.
const links = $(urlfetch json PASTEBIN_LINK); /* fetch the links */
let link = links[Math.floor(Math.random() * links.length)]; /* get any random link */
link; /* return the link, which can be used by it's alias command */
let data = $(urlfetch json $(query)); /* IIRC the ``link`` from parent command will be in $(query) */
data.items[0].title;
I haven’t tested this approach, but this more likely to work. Commands are as follows:
!addcom -cd=5 -a=__cmdName !cmdName $(eval const links=$(urlfetch json PASTEBIN_LINK); let link = links[Math.floor(Math.random() * links.length)]; link;)
!addcom -cd=5 __cmdName $(eval let data = $(urlfetch json $(query)); data.items[0].title;)
If the command doesn’t work, please feel free to ask.