HornStat

Back

The Beginning

I'll be writing about my first ever coding project. Before this, some context - I used to play this game called "Brawlhalla" and had my own clan. Being a nerd, I wanted to see information about my clan members in a neatly organized manner, and from that day started my journey of programming.

The First Experiment

Before it came to be known as "HornStat", the project started off as a small Google Sheet that had a Google Apps Script attached to it. Every day, it would call the Brawlhalla API, and then fill a new sheet with the latest clan data. Then due to growing complexities, it turned from a Google Apps Script on a Google Sheet, into a Node.js script that would run on a Heroku server, scheduled via a cron job. But this time, it now inserted the data into a MongoDB Atlas instance instead. A friend of mine would then pull that data and create nice looking charts out of it.

This setup allowed us to see various stats, such as who's been contributing the most to the clan, who contributed the least, or who had the highest growth trajectory, just to name a few.

Then, we had an idea and figured that instead of just running it on the clan members, we could also run it on the top ranked players, and collect data such as the best performing weapon, the best performing legend for that week, and many more interesting stats. And we did just that.

Every week, we would publish updates about our clan members, and also information about the current meta in the SEA servers.

The First App

Now by this point, the "HornStat" system (as we started calling it) had been well tested and actively used by our clan members. But then around that time, out of nowhere, a popular Discord bot named Gerald went offline. This happened sometime around early to mid-2021. Because of that, we couldn't use the queue command anymore. Now what is this queue command you might ask? Basically, it was one of the most used commands of that bot, as it allowed us to see who was playing at that time - players could see whether the queue was empty (and thus not worth playing) at the moment, or filled with high ranking players.

So I decided to make my own bot with that feature. I had mostly figured out how the queueing system worked by then. It simply compared snapshots of the regional rankings every x minutes. If a player's rating had changed, that meant they were playing at the moment. Do this for every player in the ranking snapshot, and you have your live queue.

With this knowledge, I got to building my first ever Discord bot. It was written in TypeScript, using a niche framework built on top of the discord.js library. Nonetheless, it was a good framework.

Two key design choices for the bot that I still remember were:

  1. The decision to keep the bot in one server only. The bot would automatically leave any other server if added to. This might seem counterintuitive, after all, wouldn't you want your bot to be used by everyone? Well yes, but my idea was - if we kept the bot in our server only, people would be forced to join our server to get the queue data, as at that moment our bot was the only service providing such information. So basically, I was sacrificing my bot server count, for the server's members count.
  2. The snipe feature. The idea behind it was very simple, so simple I was surprised no one had done it before. Basically people in our server could use the snipe command followed by a Discord user or their Brawlhalla ID, and the bot would notify them anytime that person appeared in the queue. It became the first "player tracking" (or stalking as I liked to call it) feature of its kind.

The Main Bot

After Gerald went down, new alternatives started popping up left and right, and existing competitors started gaining traction. A few of my clan members created their own bot. They were able to get it working, with some basic commands, needed help with more advanced functionality - like the queue system. So I started contributing to it, and then gradually, I just unofficially took over it as the head, mainly because the others had stopped contributing, and I was already the most passionate and knowledgeable about the Brawlhalla API anyway.

One of the biggest competitors to Gerald, even while it was still online, was a bot called "RayBot". After Gerald went offline, RayBot had become the de facto most popular bot, replacing Gerald.

I started by adding Gerald's, then Raybot's, then after that, I added new and unique features of my own on top of it. I worked on the bot from mid 2021 to early 2022, slowly adding features, creating additional external API services for it. As I kept on adding more features, the bot's user base steadily grew.

The Peak

By the start of 2022, the project was "sort-of" complete; it had all the features of the old bot (Gerald), and even everything RayBot had, and more.

The architecture of the app followed a microservice pattern. Looking back at it now, I could've made it more resilient with less complexity and less code. All main bot commands were contained in the core codebase, while components such as the queueing system and the news system were split into their own GraphQL servers.

By the end, the architecture looked like this:

(MDX import showing the complete architecture diagram)

I had plans for a web dashboard to unify all the services together as well, but before that could happen, things began winding down.

How It Ended

The bot and by extension, the entire HornStat project, came to an end by the time I finished school for the following reasons:

  • I had grown bored of Brawlhalla and lost interest in it.
  • Discord introduced major updates at that time that would've required massive rewrites.
  • Despite all the code I wrote and the ecosystem I had built, the Brawlhalla community was small, meaning even if my bot reached its absolute peak, it would remain relatively niche. The return on effort wasn't worth it anymore.
  • Finally, around that time, a friend of mine had also offered me a job seeing my work building the HornStat system. A combination of these factors led me to stop developing the project.

And with that came the end of HornStat - a project that started as a Google Sheet with a Google Apps Script and ended as the second most used bot in the Brawlhalla community, with 500 servers and 20,000 users.

Written by

Sahil Khan

At

Sat Jan 01 2022