Have you every felt like being a pain to your friends is just too much effort? Like there was a way to...automate insults?
A common issue, I know. But the world was in lockdown and I had nothing better to do (I say that as if I wasn't working on a game at the time). Anyways, my friends and I had an ongoing joke where we would insult a particular friend of ours at every chance we got, which naturally led to the need for a bot (of course) to do just that for us.
I set it up so whenever he would post a message to our group server on Discord (basically a voice and text-messaging service, for those who don't know), Morgann would automatically reply with a random insult from the list I gave him.
Morgann's ingenious insults in action. And who better to receive such a scathing remark than from Morgan Freeman himself.
Already, this was a brilliant addition to our server, but I wanted to take this a step further. So, naturally, I added a bunch of features.
Adding Insults: I was sick of having to manually add insults to a save file myself, so I gave everyone the power to.
Adding Quotes: Another running joke in our friend group is the stupid stuff we say when we're not thinking, so naturally I needed to have a system to store all of this, and show it on demand.
Targeting Someone Else: Throwing insults at one friend is fun enough, but eventually we had the need to insult other people, so I let Morgann target other people, too.
This all went well, however I had a couple of serious problems beginning to arise.
First of all, I was running the entirety of Morgann off of my computer, which meant that once I went to bed other people couldn't add insults or target people. And because nobody except me has a normal sleeping pattern, this became a problem.
Secondly, everything was stored inside a couple of .txt files on my hard drive, which meant it was very easy to corrupt data if something went wrong.
And lastly, I thought other people would want to have Morgann on their servers, and because all the save data was global, I had a serious privacy issue.
Welcome to Technical Territory
It was fairly obvious to me that Morgann was in dire need of a rework, and so I set about doing this. There was a couple of things I wanted to change the second time around, though:
Planning: The original Morgann was built around me learning Python, which meant it was messy and janky like nothing else, so I wanted to fix that with the rework.
Saving: My biggest concern with storing everything in .txt files is that they cannot handle asynchronous saving requests. Because Discord handles messages asynchronously, though, this could cause a serious problem if two people were to add an insult at the same time because corruption and stuff.
Moderator Tools: It had become clear to me by this point that Morgann could get fairly intrusive, so I wanted to allow moderators to dial back his annoyance if need be.
To fix the biggest of these issues, saving, I decided to use a fully-fledged database to store everything, and eventually settled on an SQL database hosted through Heroku. Heroku is super neat because it hosts Morgann and the database, and I can access the database from on my computer, which meant I didn't have to guess how Morgann would function before uploading it. Also, it's free.
So with that sorted, I got to work on the new update, and less than a month later I for the most part completed Morgann, with the following features added:
Removing Insults & Quotes: Everyone knows that one guy who always comes up with the worst stuff to add to the insult list (at least, I do), so I had to add the ability for moderators to remove insults and quotes.
Random Insults & Quotes: I'm not really sure about the logic behind the random insults, but it's basically the target feature but on-demand, I guess?
Insult & Quote Searching: This one ties fairly closely into removing, because when you have 80 insults and quotes, things can get a bit hectic when randomly finding insults.
Other Mod Tools: The people needed them, so I gave the ability to limit Morgann to a specific channel and add other roles to utilise mod tools (normally only server owners can use them).
WHAT I LEARNED
In the end, I learned quite a large amount from this project, actually.
Python: I pretty much learned Python over the course of about a month and a half to code Morgann, so that was nice.
Quick Project Turnover is Great: As I said, I only worked on Morgann for about a month and a half before completing him, which is the nicest feeling.
So that's all there is to know about Morgann, really. He was never really intended to be much in the way of usefulness, but through him I learned a bunch and made my friends laugh, so I see that as a win-win.