Eval combined with Random User

Asked Mar 5, 2024·4 replies·Last activity 2 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hey there! I've seen some similar posts and responses but haven't gotten my command to work with the suggestions so far. It may just have to do with how people format their responses on this site and i'm not understanding what to input, but this is what I have right now (with https changed to htps for posting here) -

!lick $(user) has licked $(urlfetch htps://2g.be/twitch/randomviewer.php?channel=$(channel))` $(eval const responses = [‘on the wenis’, ‘Ewwww’, ‘s big toe’, ‘behind the ear’, ‘WTF’, ‘last night’, ‘in the future???’, ‘s armpit’, ‘and gagged’, ‘like a dog’, ‘in the ear’]; responses[Math.floor(Math.random() * responses.length)];)

Basically, the user would simply type "!lick" and nightbot would choose a random viewer as the subject and fill in the response from the selections. Thanks in advance.

4 replies

obviously I didn't mean for there to be an emoji. The text should end with a semicolon and right parenthesis NOT the winking emoji.

Hey @Windy Cat!

The random viewer API you're using is no longer working due to Twitch breaking changes, use this one instead:
/t/new-random-viewer-api/1534651248391880806

Next, beside a few quotes mistakes, your code is correct, here's a fix:

$(eval const randomChatter = '$(urlfetch https://commands.garretcharp.com/twitch/chatter/$(channel))'; const responses = [' on the wenis', ' Ewwww', '\'s big toe', ' behind the ear', ' WTF', ' last night', ' in the future???', '\'s armpit', ' and gagged', ' like a dog', ' in the ear']; `$(user) has licked ${randomChatter}${responses[Math.floor(Math.random() * responses.length)]}`)

Here's what I have now. The RandomChatter is working but I can't get the Random Response to work.

!lick $(user) has licked $(urlfetch htps://commands.garretcharp.com/twitch/chatter/$(channel)?moderatorId=190525736) $(eval const responses = ['on the wenis.', 'Ewwww.', 's big toe.', 'behind the ear.', 'WTF!', 'last night…', 'in the future???', 's armpit.', 'and gagged.', 'like a dog.', 'in the ear.']; responses [Math.floor(Math.random() * responses.length)])

When I try the command the response I get looks similar to this

XXXXXX has licked YYYYYYY $(eval const responses = ['on the wenis.', 'Ewwww.', 's big toe.', 'behind the ear.', 'WTF!', 'last night…', 'in the future???', 's armpit.', 'and gagged.', 'like a dog.', 'in the ear.']; responses [Math.floor(Math.random() * responses.length)])

I don't understand why it's not computing the random responses.

it needs one more close parenthesis at the end... but i highly recommend u use the version @Polar Cat gave u, as her version fixes the grammar for the possessive ones... aka, so it'll say "user's big toe." instead of "user s big toe."
edit: oops, it's not the close parenthesis... it's the space between "responses" and the open bracket "[" right before "Math.floor"