Inspiration

Several months ago, a friend of mine (with significantly more coding experience than me!) introduced a Markov's Chain-powered chatbot to our Discord server. The bot has since stopped functioning for reasons beyond my understanding, but I've always been curious about what it would take to build one of my own -- and what better time and place to try it out than at a hackathon?

What it does

After adding Kenku Bot to a Discord server, members can <(optin to allow the bot to start recording their messages (or <(optout anytime to put message collection on pause). Once it's collected enough message data, the <(mimic command will prompt it to generate a sentence of its own based on the messages it has learned from opted-in members. Kenku also responds to its own name in the same way as the <(mimic command.

How I built it

Lots of tutorial-watching and article-reading! I learned to host Discord bots from freeCodeCamp.org's YouTube channel, and modified the Markov's Chain script to pull from my own ever-changing database rather than a .txt file from an open-source script on Tech.io.

Challenges I ran into

The previously-mentioned database was the hardest part: just as with the Discord API, I was learning to use repl.it's built-in database for the first time, armed with little more than the absolute basics of Python knowledge. However, unlike the Discord API, I struggled a great deal to find documentation or even advice on how to use it, and without an understanding of the coding "vocabulary" I needed to communicate my intentions, I often found myself stuck on how to search for how-to's regarding even the simplest tasks.

Accomplishments that I'm proud of

The opt-in/opt-out system is a special point of pride of mine - being entirely dependent on the very same repl.it database that gave me so much grief, it took a lot of trial and error to work out, so I'm pleased to say it finally functions exactly as it was intended to!

What I learned

  • How to create a bot with Discord's API
  • How to use repl.it's built-in database
  • How to keep a browser-based script running indefinitely
  • Basics of dictionary objects
  • Basics of pickling

What's next for Kenku Bot

  • Command to generate a message from one user's specific message data, rather than the entire server's
  • Additional commands to generate messages from fixed sources (ie. podcast transcripts, musical theatre librettos, etc.)

Built With

Share this project:

Updates