Discord Bot In F#

I did software dev for 12 years (SQL, c#, Microsoft MVP), but I’ve been ‘not a dev’ for almost as long now. Devember is my excuse to code something and learn a new language that really piqued my interest.

That was cool, but watching this next one made my brain spin for days. I couldn’t stop thinking about all of the no-good, terrible, awful object-oriented business domain models I’ve had to work on.

OO is evil.

I decided to build a Discord bot to help a friend. He’s a content creator and likes to plays with subs, but finds it hard to manage hundreds of people fairly. He’s tried a number of existing queue bots, but they all had quirks.

With a new language and a foreign API, I decided to wait until it started coming together to share:

2 Likes

That sounds like a fun project!
My Devember project is also faintly similar (using FP and a chat-API).

I’m curious if you’re allowing yourself to use some of the OO and procedural features that F# also has, or if you’re restricting yourself to go “head first” purely functional?

1 Like

I’m doing my best, but it has proved challenging to stay pure. On the one hand, I spent a week removing a working, bog standard OO circular dependency. On the other, I need to maintain state in a multithreading environment. Not to mention the Discord.NET wrapper is an OO rats nest.

This is the heart of the bot. It does all of the state management and input processing with a somewhat hybrid approach. It should be purely functional everywhere else.

1 Like