SiebeBaree / Coinz

An advanced Discord economy bot with real-time financial data, minigames like blackjack, roulette, and business management features.
https://coinzbot.xyz
GNU General Public License v3.0
9 stars 0 forks source link

Market info lastUpdated triggers an error #3

Closed kokoiro closed 2 years ago

kokoiro commented 2 years ago

Describe the bug Every time you send /market info, the bot crashes.

Used Command or Event /market info

Expected behavior Get info about the available stocks.

Error TypeError: Cannot read properties of undefined (reading 'lastUpdated') at createEmbed (src\commands\stocks\market.js:20:184) at execInfo (src\commands\stocks\market.js:97:48) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Object.module.exports.execute (\src\commands\stocks\market.js:264:64)

SiebeBaree commented 2 years ago

Hi, that error is because you don't have a valid stocks database. It tries to read a field inside of a document but that document is "undefined".

To use the market feature you also need to use Coinz-Scripts. That repository does all the work for you in creating stocks and crypto and committing them to the database. That script needs to run 24/7 to update the database regularly.

To use the Coinz-Scripts repository add your own stocks in the markets.json file under "stocks": [], use ticker symbols like "AAPL", "AMZN", "MSFT", "TSLA"

For Crypto Coins add your own coins in the crypto.json file under "crypto": [], use ticker symbols like "BTC", "ETH", "DOGE", "SHIB"

You also need to create 2 API keys. (one for the stocks API and one for the Crypto API) Stocks API: https://rapidapi.com/principalapis/api/stock-data-yahoo-finance-alternative/ Crypto API: https://docs.bitvavo.com

Note that Bitvavo API prices are in euro and not dollar. The stocks API has a rate limit of 1000 requests/month and the crypto API has a rate limit of 1000 requests/minute.

I will add code later that prevents this error and gives a better error message in the console of what to do.

kokoiro commented 2 years ago

Thank you so much @SiebeBaree.

By the way, theres no "example.config.py" mentioned in your readme.

SiebeBaree commented 2 years ago

Thanks for letting me know, I updated the README with new information.