Meet Pymon: A Discord Bot That Can Answer Any Question You Want

Meet Pymon: A Discord Bot That Can Answer Any Question You Want Featured Image

Guess what! I made another Discord bot, and you can’t stop me. This time, it’s an educational bot that can answer computer science questions. Plans are to set it up to answer any questions you’d like.

Table of Contents

Discord Bots

As you may have noticed, I’ve been on a bit of a Discord bot kick lately. It all sort of started when I jokingly made a bot for my personal Discord. Since then, I’ve been making all sorts of articles about them:

Well, as you can probably imagine, I finally made a Discord bot for my students. I’ve called it Pymon as a silly pun between the character from Genshin Impact and the programming language, Python. Let’s talk about what it does!

Providing Education

If you teach the same class for long enough, you’ll start to get repeat questions from students. I tend to have a short memory, so I don’t mind this. That said, there are always questions that I get tired of answering.

In general, I find there’s two ways of dealing with this. For one, you just have to become a better educator by finding ways to make the material easier to digest. Even in a perfect world, however, students are still going to get stuck. As a result, it’s always nice to have resources that you can share with students to save yourself some time.

For a long time, I had been writing articles to share with my students. Then, I made rubrics and checklists to further support their work. Finally, I came up with the idea of a Discord bot that could store answers to student questions like an FAQ. To me, this was a much better solution than referring students to a document because that always felt sort of elitist or arrogant (i.e., it gave me RTFM vibesOpens in a new tab.). Instead, students could opt into asking the bot for help, which could be faster than asking me or the graders directly.

As an added bonus, I could crowdsource questions from students to add to the bot, and I could even base future content off the various queries students might have. To me, it really brings home the one thing I really love about software development: working together as a community.

Introducing Pymon

So, what exactly is PymonOpens in a new tab.? Well, Pymon is a Discord bot that functions off a queries file that takes the following form:

[
  {
    "query": "What is Pymon?",
    "response": "Pymon is a Discord bot that provides answers to common queries.",
    "resource": "https://therenegadecoder.com/teach/meet-pymon-a-discord-bot-that-can-answer-any-question-you-want",
    "credit": ["Jeremy Grifski"]
  }, ...
]

This file is JSON, and it functions as the “brain” for the bot. Basically, we load up this file with a list of dictionaries that contain questions students might ask with their respective answers. I also include a credit line for the person who created the query and an optional resource line if there’s an existing resource that can further address the query.

The bot itself then does a bit of “thinking” once its brain is loaded with queries. Specifically, it generates associations between queries to generate a set of related queries. That way, when a student asks the bot a question, the bot can refer them to queries that are closest to their question. Likewise, once they receive an answer, the bot can direct them to other related answers.

Overall, the logic used to get Pymon working isn’t too complicated. There’s no AI at play. It’s more or less like an old school search engine. We break the search string into tokens and try to find queries that most closely match those search terms. For performance reasons, a search term mapping to queries already exists (i.e., the knowledge is already indexed), so we don’t run through the entire database with each search.

To ask the bot a question, you just tag them using @Pymon. As long as the bot is properly hosted, you should get a response ASAP. At the time of writing, Pymon featured 40 queries with many more in the works.

Future Work

Pymon currently only supports queries for the course I am teaching. That said, I am interesting in maintaining multiple sets of queries that could be loaded and used for different classes or contexts. In general, I would love to have Pymon be able to take a new queries at any time through something like a Slash command. That way, folks could add their own data sets.

In the short term, however, Pymon is for personal use. If you’d like to host Pymon yourself, you’d have to fork the repo and go through that process. I currently host my version of Pymon locally on a desktop. Surely, if you have the resources, you could properly host it.

With that said, that’s all I have to say about my new bot! Let me know if it sounds interesting to you. I’d love to see how other people use it. Otherwise, here are some related articles:

Likewise, here are some resources from the folks over at Amazon (#ad):

With that said, take care! See you next time.

Jeremy Grifski

Jeremy grew up in a small town where he enjoyed playing soccer and video games, practicing taekwondo, and trading Pokémon cards. Once out of the nest, he pursued a Bachelors in Computer Engineering with a minor in Game Design. After college, he spent about two years writing software for a major engineering company. Then, he earned a master's in Computer Science and Engineering. Today, he pursues a PhD in Engineering Education in order to ultimately land a teaching gig. In his spare time, Jeremy enjoys spending time with his wife, playing Overwatch and Phantasy Star Online 2, practicing trombone, watching Penguins hockey, and traveling the world.

Recent Posts