Monumenta Item Index
There are a lot of items in Monumenta, and though there had been independent attempts to catalog them all, there wasn’t a central, publicly available index. In April of 2019, a friend of mine started building a Discord bot for a public item index, and I wanted to help.
For context, Monumenta is the game I was developing the bot for – I used to be a mod, but I retired around the time I was building the bot.
Discord Bot 1.0
My friend had started using discord.py v0.16, the older but still very functional Python library to make a Discord bot. Initially, all the items were stored in a local text file, and the bot was mostly string parsing for that text file. Discord.py was surprisingly easy and intuitive to work with, so I helped write a helper class and some better searching/parsing code for the items, including a more complex tag system. Since this was technically production level, I figured I should follow best practices, so I modularized functionality, made better security for bot secrets, and added additional functionality for users to reference game functions.
The first major overhaul I did was for the database, moving from text files to Firebase, using Realtime Database. This made initialization and database reference considerably more complicated, but it was definitely worth it to retire the text files we were using before. The bot, upon initialization, would simply call the database for every single item; upon lookup, it could do a fast local search for the item in question. Using Realtime Database made this process super easy, since tags and the item’s image url could be stored as attributes onto an item name. Sometime after finishing moving to Firebase, I moved hosting services to Heroku.
The second major overhaul was to integrate one of the previously mentioned independent catalogs of items. This one was very thorough and recently released at the time, so I wrote some code to scrape the spreadsheet and add all the items to the index. This was a significant change – before, players would add items manually, but now this Discord index was comprehensive and accessible, without the need for any active maintenance (at the time). I took a break from working on it for a few months, coming back to add some fancy formatting and styling, as well as a trade system, but it wasn’t in active development for several months.
So, at the time, the bot was comprehensive and useful. However, Monumenta released region 2, introducing a whole new set of items to be catalogued. However, I wasn’t playing much of the game, and the spreadsheet author stopped maintaining that index. The bot became relatively obsolete, so, in March 2020, as quarantine began, I decided to revisit the project and update what I could.
I made the overhaul with a couple of goals in mind:
- allow players to easily add items and tags
- quick and powerful searching that could cover spelling errors
- making a website to better display the items
- refactor from Realtime Database to Firestore, a more modern database system
For myself, I wanted to make something with React, as it is one of the most popular and frequently used frameworks out there right now. I also wanted to put this project in low-maintenance mode, where I didn’t have to come update it again for more systems or anything, so I was aiming to build a generic system that I could forget about.
I wrote a number of migration functions within the Discord item index bot’s repo, as it has the perms to access the database. The migration was surprisingly annoying, as JSONifying the Realtime Database data created some strange formatting bugs. However, when I did figure it out, I realized how much easier Firestore was going to be to work with – the document collection structure is far more intuitive for an item index system. The most annoying part of the migration was accidentally capping out my rate limits, as I had to move a detailed item index, and I wasn’t very successful at first.
Though I had no React-specific experience, I had some experience with React Native, and that knowledge was quite transferable. The router, screen prop sharing, and styling code was all very similar, and the documentation for React is solid. Initially, I tried to keep my own styling as much as possible, but I ended up using Material UI – though it made styling easier, I’m still not sure the overhead is worth it. However, though the website itself is simple, it took me a few weeks to get the styling the way I wanted it, and again, since this is technically production level, I tried to follow React best practices as much as possible.
Searching with Algolia
Algolia is an excellent search API that I mistakenly believed was only for enterprise before this project. Because of my code with the database migration, putting all the items into an Algolia index was pretty simple, and I was able to get a search function up and running extremely quickly. I’m really happy with using Algolia; I no longer had to write any spellcheck or similarity checker functionality – it was just all in Algolia already. The search engine is super fast both on the website and on Discord, and all I had to do for maintenance was write some additional database code for the index.
To make the project as low-maintenance as possible, I built a bunch of database modification functions in the website to add, remove, and modify items in the index. This introduced the most major complication and annoyance within the project – how to authenticate a potential editor of the index. In the end, I chose not to deal with the issue; rather than good practices, I’m just making backups every day, so if the database is tampered with I can roll changes back.
I published the website with Firebase hosting on a random domain I bought a while ago – check it out here, and I rolled out my changes to the bot on the public Discord.
Reflection and Future Plans
This was one of the more satisfying projects I worked on, as people actually used and still use it regularly. However, I’m still unhappy with how little the changes I made have an impact on the usage – when I added the trade function, only one person noticed I added it at all, and when I made the website so people could add items, very few people added anything. I still like this project as a great generic template, especially my React code – I want to go back and style everything more nicely, and clean up some of the worse code I wrote to push out the 2.0 version ASAP. React is a nice framework for web dev, and I’m happy with a lot of the functionality I built into the website, even if it is aesthetically terrible.