../discord-bot

4 minute read

This project was quite interesting. It all started because the Discord server I spent the most time on had lots of fun/heated debates and it seemed like people wanted to vote on things / take polls.

Not sure who's idea it was, but I do remember thinking it was within my technical limitations and also had a new toy in Rust and the magical Cargo with its seemingly endless possible libraries to include in your projects.

So I found a library that handled most of the boiler plate and coded up a simple discord bot to craft "polls" from users via chat commands and then output a new message, with the numeric emojis as reactions for people to vote with. It was cool but I had a very loose understanding of databases and callback functions at the time, so I never got around to closing the polls and declaring a winning answer for that particular poll.

Artifact🔗

After that I added integration with my Artifact library so that users could lookup cards by substring search or pass in deck codes and get a message out with a summary of what cards it contained. This was a pretty fun feature to implement and looking back on it I envy my drive to iterate and improve it, but also due to the niche nature, was not used too much.

DotA🔗

At some point I added a random command for DotA heroes, that was a quick 15 minute feature that does not really do anything fancy, just uses a local static file commited in tree to pull its info from. This probably got used more than the Artifact stuff.

Tipping🔗

The marquee feature of the bot, which drove the desire to build a web API for it, was tipping. DotA had recently introduced a tipping mechanic in game, such that, you could hand out a limited number of tips per week to other players. Funnily enough, tips were often used maliciously, to taunt the enemy team for poor plays or to mess with you allies after they messed up. This was a pretty interesting feature as it allowed people to trade tips as a sort of fiat currency for compliance in game or debates. At some point it was brought up that there was not enough of a positive emotion attached to tipping, and as it was basically a weekly/lifetime leader board, bad manner tip's context were lost and therefore not as good as in a game of DotA where the visceral nature of the popup is enough of an incentive to use tips in that way.

To remedy this, I added an "anti-tip" component, with much fewer anti tips per week compared to normal tips. This led to a lot more engagement with the system. It also sowed discord in the Discord server. I tried a few different methods of preventing anti-tip abuse, such as keeping a separate tip count for raw tips recieved and tips minus anti-tips in a sort of gross/net dynamic. This project ultimately included too many psychological and social factors that I was not really interested in balancing so I just left it running on my Rasperry Pi 3 until I couldn't be bothered to anymore.

API🔗

The API came about as a way to allow me to run the bot agnositically and keep track of tip counts properly. I just made simple REST API for handling tip related stuff and kept all the data stored in a PostgreSQL database on heroku. Nothing too crazy here, just used the user's Discord id's to keep track of who tipped who when and their running totals.

Key takeaway🔗

This was a hugely beneficial project to work on just in terms of improving confidence in my own ability and also familiarizing myself with how a lot of various "Real World" things pass data around. Ultimately I am glad I did it, but given the opportunity/idea, I would probably just make it a web app first with discord integrations as a secondary interface. I think fun toy projects like this which you can show off are a great place to start.