A simple Fetch Data from User Input

Ok, once again it is the easy things that escape me but after 2 days of searching and reading 50 posts that are close but I still can’t get it to respond the way I want…

This is the code I have working now

$(eval cards = $(urlfetch json https://pastebin.com/raw/M58LaWUF); pick = cards[Math.floor(Math.random() * cards.length)]; $(user), your energy sent ${pick.name}! which is ${pick.meaning}.:wink:

This reads the pastebin and returns random values…

“name”: “Adamite”,
“meaning”: “The Stone of Playful Nature”
“name”: “Aegirine”,
“meaning”: “The Stone of Conviction”
“name”: “Agate”,
“meaning”: “The Stone of Inner Stability”
“name”: “Almandine”,
“meaning”: “The Stone of Truth”

What I am attempting to do is return a specific value on user input

EX User1: Agate
Nightbot: $(user) You asked for Agate and it is The Stone of Playful Nature

Any guidance is appreciated - JTS

I am still very stuck on what should be a very simple call… this is so frustrating. Getting old stinks.

NO matter what I have tried I can’t get the command to complete. It does as a random pull but still can’t figure out how to make it pull a specific set

Any help is appreciated - JTS

As long as your using Math.random() if will always return a random response. Below is an example to get a specific name using Array.find().

$(eval const res = $(urlfetch json https://pastebin.com/raw/M58LaWUF); const pick = res.find(obj => obj.name.toLowerCase() === '$(1)'.toLowerCase()); `Name: ${pick.name} - Meaning: ${pick.meaning}`)

Works perfectly thank you so much. I have beat myself stupid and just got all turned around… Thank you for your effort and energy