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.
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: Late-night gaming sessions lead to some cracking quotes being said, and naturally we needed a system to store and show them 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.
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 had, 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).
In the end, I learned quite a large amount from this project, actually.
Firstly, I pretty much learned Python over the course of about a month and a half to code Morgann, so that was nice. Additionally, I realised that quick project turnaround was a huge plus, and it allowed me to move onto other projects and experiment with different things.
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.