A Discord bot that integrates with OpenAI's GPT-3.5-turbo to answer questions via slash commands and text commands.
- Slash command
/ask
to get answers from GPT-3.5-turbo. - Text command
.ask
for the same functionality. - Configuration via a
config.json
file.
- Python 3.10 or higher
pip
(Python package installer)
git clone https://github.com/adityakumarxd/chatgpt-discord-bot.git
cd chatgpt-discord-bot
Create a virtual environment (recommended) and install the required packages:
For Windows
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
For macOS/Linux:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Create a config.json file in the project directory with the following structure:
{
"bot_token": "YOUR_BOT_TOKEN_HERE",
"openai_api_key": "YOUR_OPENAI_API_KEY_HERE"
}
Replace "YOUR_BOT_TOKEN_HERE" with your Discord bot token and "YOUR_OPENAI_API_KEY_HERE" with your OpenAI API key.
For Windows:
python main.py
For macOS/Linux:
python3 main.py
Once the bot is running, you can use the following commands in your Discord server:
Slash Command: /ask - Use this command to ask a question and get an answer from GPT-3.5-turbo. Text Command: .ask - Same as the slash command, but uses the text command format.
For any questions or feedback, please contact me on Discord akxd
.