Wizard AI chat bot that roasts my friend
My friend group's discord server needed a bit of spicing up. But also, one particular friend from that same server, is shorter than me by 1 inch and I wanted to make sure he was reminded of that as often as possible. So to kill two birds with one stone, I made an AI powered discord chat bot that uses his magical powers to answers all of the questions of the universe while also making personally addressed snarky comments at that particular friend of mine.
Technical Overview
It works by connecting Discord to Open AI's Chat GPT using their respective APIs. To do this I used Python. Here is a block diagram of how it works.
How it works
The Discord API is always talking to the Python script. By this I mean that the Python script reads every single message that is sent through the discord. If a message starts with the key word "!ask", it kicks off a chain of events.
The first step is to delete the "!ask" part of the input message and then figure out who sent the message. After that, the message along with the username of the person who sent it, gets appended to a prewritten string saved as a variable.
This string, with the username and question, gets sent to Chat GPT through the Open AI API. That looks something like this.
The response then gets saved in the variable "wizard_response" and afterwards gets sent to the discord channel.
Honestly, that is pretty much it. Super simple.
Conclusion
This was a simple single day project that is part of a running joke me and my friend have. It achieves its goal, but there are a few things that I would like to improve on. For one, I would like for it to learn from past messages and progressively learn from things from individuals based on things that have been said in the chat. For this I would have to save the chat logs onto a .txt file, and when the wizard is summoned, I would have to pass the saved text and the prompt to the Chat GPT API.
Another thing that would be cool was if it just randomly without being prompted, decided to start talking. This would be a bit creepy but hilarious. Imagine the bot just decided to randomly roast my friend when literally no one is expecting it to. For this I would have to put some sort of timer. After the time reaches a certain point, the Python script could automatically begin sending messages using a prewritten prompt.
All in all this was a fun simple project, that helped me learn how to use Chat GPT's and Discord's API.