Inspiration

With school being virtual this year, my friends and I have taken to Discord as our place to study, chat, and chill. Always eager to add to our server, I thought a friendly bot would be a nice addition, and what better than a cute little corgi? Not only does it keep us laughing with its sharp little quips, but it keeps us up to speed on our science knowledge!

What it does

Once Corgi bot is added to a user's server, they type Hi Corgi Bot in order to activate it. Corgi bot then creates a channel called corgi-land and sends out a welcome message with instructions.

Corgi bot can:

  • send random memes via the !corgi meme command
  • respond with gifs to various keywords (i.e. if a user's message includes food or code or hoot for example)
  • give "money" to users via the !corgi give me money command (a random amount between $1 and $10), but only if they can first correctly answer a trivia question with a science theme
  • help users adopt a virtual corgi for $50 (!corgi adopt) which they can then name (!corgipet set name _name_)
  • help users buy accessories (for $5) or sell accessories (and receive $5) via the commands !corgipet buy _item_ and !corgipet sell _item_

How we built it

Corgi bot is built in javascript, specifically Node.js. It uses sequelize and sqlite3 to build and manage a relational database with two tables. The first table keeps track of the various users, the amount of money they have, what color corgi they were randomly generated upon adoption, and which accessories they own. The second table contains ~300 science-themed trivia questions and answers (which I scraped from Reddit user @trexmatt's csv file of all past Jeopardy questions). Linode was used to host a virtual private server for running Corgi bot on continuously. SSH access was used for file transfer and to provide a coding environment and pm2 was used to keep processes running. *Note: * I have shut down Corgi Bot for a few hours so I don't run out of funds, but will re-start it Sunday morning around 12 PM EST (due to time zone differences)

Challenges we ran into

Figuring out discord.js and sequelize was particularly challenging since I had never worked with either technology before (many, many hours were spent logging and debugging). Additionally, I had never used Linode before, but luckily the Docs were very comprehensive and helpful for getting started!

Accomplishments that we're proud of

I had never built a Discord bot that actually worked, so I am proud that I now have one that my friends and I are enjoying. Additionally, I am proud that I was able to apply the skills I gained in my courses at school (specifically those surrounding databases) in a self-led project. I'm also very proud of the cute little corgis I drew!

What we learned

I learned how to build a Discord bot and implement database functionality. I also learned about the concept of asynchronous functions (and how if you're going to use a variable from an asynchronous call, you have to wait for it to be returned _or you will get an error). Another important concept I learned was about ssh access and how to host/run an application somewhere other than on my local computer (which is important if other people want to use my bot!).

What's next for Corgi Bot

I hope to keep expanding Corgi Bot's functionality in the future! Next, I would love to implement some sort of multiplayer game! Perhaps it could be related to science trivia. I would also like to play around with building a web scraper so that users could ask Corgi Bot a question, and Corgi Bot would return a relevant link/blurb from the internet!

Built With

Share this project:

Updates