Unexpected identifier

I want to add a random facts command, but when I type the command it displays error: Unexpected identifier
!command add !fact $(eval a=$(urlfetch json https://pastebin.com/raw/x0vgXCwJ);a[Math.floor(Math.random()*a.length)])
please help


Hey @Ritik_Ranjan!

There are inconsistencies in your Pastebin, well, not from a human point of view, but from a code point of view: you end each facts with a , (comma), yet in some of your facts there are commas, which would create a new item.
Also, for some reasons, I rarely manage to make an array work when they come out of a raw Pastebin, I rather build it inside the command to be sure it works properly, it never fails by doing it like this, so finishing your items with something else than a comma, something like a | (vertical bar) is a good solution in my opinion.
And using " (double quotes) inside of ' (single quotes) can mess with the code as well. I personally recommend using ` (backticks) instead of quotes, that way you don’t have to worry too much about quotes inside of your items.
With all this in mind, here’s what it looks like:


North Korea and Cuba are the only places you cant buy Coca-Cola.| 
The entire worlds population could fit inside Los Angeles.| 
More people visit France than any other country.| 
The Canary Islands are named after dogs, not birds.| 
Indonesia is home to some of the shortest people in the world.| 
The Paris Agreement on climate change was signed by the largest number of countries ever in one day.| 
The worlds quietest room is located at Microsofts headquarters in Washington state.| 
There are only three countries in the world that dont use the metric system.| 
The longest place name on the planet is 85 letters long.| 
Four babies are born every second.| 
The coldest temperature ever recorded was -144 degrees Fahrenheit.| 
The Earths ozone layer will make a full recovery in 50 years.| 
There are around 4 quadrillion quadrillion bacteria on Earth.| 
People who are currently alive represent about 7 percent of the total number of people who have ever lived.| 
Muhammad is thought to be the most popular name in the world.| 
Only two countries use purple in their national flags.| 
Africa and Asia are home to nearly 90 percent of the worlds rural population.| 
The most expensive coin in the world was sold for more than $7 million.| 
South Sudan is the youngest country in the world.| 
More than 52 percent of the worlds population is under 30 years old.| 
Nearly half of the worlds population watched both the 2010 and 2014 FIFA World Cup games.| 
All giant pandas in zoos around the world are on loan from China.| 
The red-billed quelea is the most common bird on Earth.| 
Theres a website that tracks the worlds population in real-time. https://www.worldometers.info/| 
More people speak Mandarin Chinese than any other language.| 
There are 41 countries that recognize sign language as an official language.| 
The global adult literacy rate is around 86 percent.| 
Facebook has more users than the population of the U.S., China, and Brazil combined.| 
All the ants on Earth weigh about as much as all the humans.| 
The oceans contain almost 200,000 different kinds of viruses.| 
New Zealanders have more pets per household than any other country.| 
Tokyo is the worlds largest city with 37 million inhabitants.| 
Nearly two people die each second.| 
There is a technical name for the "fear of long words": hippopotomonstrosesquippedaliophobia.


!addcom !fact $(eval a=`$(urlfetch json https://pastebin.com/raw/XXXXXXXX)`.split(`|`);a[Math.floor(Math.random()*a.length)])

Thank you so much for help. :wink:
Literally, thanks

1 Like

Great job brother nice command

1 Like

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