OpenAI Discord Chatbot

Purpose

The purpose of this project is to create a ChatGPT bot for Discord, providing users with a convenient utility of OpenAI when they are away from their desktop or laptop. It enables users to ask questions on-the-go and display answers and solutions while the user returns to their computer.

Functionality

Users can engage in interactive and dynamic conversations with OpenAI's ChatGPT API.

Users can send and receive direct messages, allowing for private and personalized interactions.

The chatbot maintains separate conversations between multiple users, ensuring that it stays focused on the topic at hand without being influenced by other users.

Challenge

One issue I had was a relatively quick-fix, but it involved having the chatbot be able to read and store past conversations. The issue was that it won't differentiate between different users, and will continue a conversation branch based on the past questions regardless of who asked them. The fix I included into the code involved stopping the chatbot from responding if the author of the message is either not a bot itself, or if the current author of the current question is the same as the previous author of the previous question, then it will check the chat history until a certain amount of submissions by the current author has been reached.