Made my first Discord bot!

A few weeks ago, I posted a "ttrpg initiative tracking" program I had written for practice. Using the advice I received here, along with finishing The Book, I rewrote this program into something much better.

The biggest change was reducing coupling between modules. And I changed every function/method that printed to the output to instead return a String, and had a single output() function.

This neatened code structure made it very easy to covert the program to a Discord bot. All input gets sent to a "command" module, which returns a "response" String. I then built up "main()" to support bot operation per a tutorial, and simple moved my top-level code (about six lines) into the "message receive" logic. And after a bit of trial and error, I got it working!

I just wanted to share my excitement with the community, and thank you all for being a great support network.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.