Randomly pick a Tarot card and give its meaning

So, I am attempting to figure out an if then output for nightbot. The idea is based on a random choice and then I would like it to fetch info from a pastebin.

Ex: User:!tarot
Nighbot: [(User) you pulled The Tower] and it means xxx
this part works This is the part I am missing

First is a simple Eval which I have this chooses the random from the list

$(user), You drew $(eval responses=[The Fool!,The Magician!,The High Priestess!,The Empress!,The Emperor!,The Hierophant!,The Lovers!,The Chariot!,Justice!,Strength!,The Hermit!,Wheel of Fortune!,The Hanged Man!,Death!,Temperance!,The Devil!,The Tower!,The Star!,The Moon!,The Sun!,Judgement!,The World!];responses[Math.floor(Math.random()*responses.length)])

If output =The Fool then fetchurl line 47
but would i need this for each of the choices?

The next part is where I am stuck I am trying to code an if/then to display the meaning of said card. So I am trying to get it to evaluation the “list” of meanings. The file is too big to include in the command so I have a file ready to pastebin I just can’t figure out the second part of it. There are lots of random picks but I need it to display a specific meaning based on the output of the first command.

Ex: !Itarot
Nightbot [output], eval pastebin link, return proper meaning…

Any help is greatly appreciated.

Hey @Jeffrey_TheSeer!

I have a solution for you, but that will require a bit of a change in how you made your cards list, but you will only need a single command, no alias, it simplifies things a lot and makes for a more efficient code.

First you’ll have to create a Pastebin like this:

    "name": "The Fool",
    "meaning": "a beginning of a new journey, one where you will be filled with optimism and freedom from the usual constraints in life"
    "name": "The Magician",
    "meaning": "that it's time to tap into your full potential without hesitation"
    "name": "The World",
    "meaning": "fulfillment, achievement, and completion"

Then your command will be:

$(eval cards = $(urlfetch json https://pastebin.com/raw/XXXXXXXX); pick = cards[Math.floor(Math.random() * cards.length)]; `$(user), you drew ${pick.name}! In Tarot, it means ${pick.meaning}.`;)

That was a great move thank you. The chat xgtp was my first thought was more looking for a way to access it from another app and then used this as the example. I just couldn’t remember how to achieve this and you made it so simple. Thanks a bunch for the bail out now I can finish my project.

1 Like

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