Stock price Discord bot

Sean
SLTC — Sean Learns To Code
2 min readJan 15, 2023

This weekend I set aside some time to work on one thing that I’ve always wanted to do for a while: to build a Discord bot that tells me the latest stock price given a ticker symbol. Let’s say we’re in a Discord channel and I enter the following message into the channel

Me: $stonk AFRM
Stonk Bot: $999.999

At one of my previous employers we had a Slack bot that does the same thing. It was quite a ride giving the rise and fall of the US stock market in 2020, 2021, and 2022. Market movements aside, I have always been curious how the bot was built and I guess the best way to have a better understanding about that the Slack bot to build something similar myself.

So how did it end up to be a Discord bot?

It’s because I happen have the admin role of a Discord server so I think it’s probably easier if I start out with Discord and take advantage of the higher level of access granted to an admin. With great power comes great responsibility and all that stuff, you know.

After spending 2~3 hours of my Saturday afternoon, here’s what I was able to come up with

The source code can be found on GitHub here: https://github.com/seanluong/stonk-bot.

Beside gaining some exposure with the Discord API that is used to build a bot, I also learned about 2 other nice things that I will cover separately in the future: Replit and yfinance. They both are very important tools that helped me in building the bot.

To the moon 🌕!

--

--