This repository contains the code for a simple Discord bot that uses OpenAI's GPT-3 model to respond to user queries.
- Connects to Discord using the discord.py library 📡.
- Responds to user commands prefixed with '!' 📣.
- Filters out non-alphanumeric characters from user queries 🗂.
- Sends user queries to the GPT-3 model and returns the response in the chat 💬.
-
Install the required Python libraries by running: 📚
pip install -r requirements.txt
-
Add your Discord token and OpenAI API Key to a .env file: 🔑
DISCORD_TOKEN=your_discord_token OPENAI_API=your_openai_api_key
-
Run the bot.py script: 🖥
python bot.py
-
In Discord, use the '!gpt' command followed by your query: 💻
!gpt your_query_here
- discord.py
- python-dotenv
- openai
To obtain the OpenAI API key:
- Sign up or log in to the OpenAI website.
- Navigate to the API section in your account settings.
- Generate a new API key and copy it.
To obtain a Discord token:
- Go to the Discord Developer Portal and log in.
- Click on "New Application" to create a new bot.
- Go to the Bot settings, click on "Add Bot".
- Under the "Token" section, click on "Copy" to copy your bot's token.