Requirements
This project requires python version 3.12.3 discord.py version 2.3.2, OpenAI version 1.30.1 and python-dotenv version 1.0.1 which can be installed…
This project requires python version 3.12.3 discord.py version 2.3.2, OpenAI version 1.30.1 and python-dotenv version 1.0.1 which can be installed…
This project requires python version 3.12.3 discord.py version 2.3.2, OpenAI version 1.30.1 and python-dotenv version 1.0.1 which can be installed via requirements.txt:
pip install -r requirements.txt
pip install discord.py~=2.3.2
pip install openai~=1.30.1
pip install python-dotenv~=1.0.1
.env File settup.env file in the bot's root folder. (Same folder as main.py).env file as follows, replacing TOKEN_HERE, OWNER_UID_HERE, CHAT_GPT_API_KEY_HERE, DISCORD_SERVER_1 and DISCORD_SERVER_2 with your bot's token, your Discord UID, ChatGPT API key and discord server ID's respectively. Keeping the double quotation marks.BOT_TOKEN = "TOKEN_HERE"
OWNER_ID = "OWNER_UID_HERE"
GPT_API_KEY = "CHAT_GPT_API_KEY_HERE"
DISCORD_SERVER_1 = "FIRST_DISCORD_SERVER_ID_HERE"
DISCORD_SERVER_2 = "SECOND_DISCORD_SERVER_ID_HERE"
For example:
BOT_TOKEN = "12ab56c89"
OWNER_ID = "123456789"
GPT_API_KEY = "12ab56c89"
DISCORD_SERVER_1 = "123456789"
DISCORD_SERVER_2 = "123456789"
OWNER_ID, DISCORD_SERVER_1 and DISCORD_SERVER_2 must be a numeric whole value
.gitignore file will ignore the .env.If you want to change the location of the .env file, you will need to make a reference for it by adding:
dotenv_path = os.path.join("path/to/env", ".env")
above load_dotenv(override=True) and update load_dotenv(override=True) to:
load_dotenv(dotenv_path, override=True)
If you want to change your .env file name as well add this reference to the .env:
dotenv_path = os.path.join("path/to/env", "Env_Name_Here.env")
Open a new command line in the same folder as the main.py script (Make sure python is installed and/or your python venv is active) and type:
python main.py
New Application button at the top right of the page next to your discord profile picture.Bot page on the left navigation pannel as shown below:USERNAME if desired.Reset Token button and copy your bots token for use in the .env file. You will have to reset the bot token to view and copy it again.OAuth2 page on the left navigation pannel as shown below:bot under OAuth2 URL Generator SCOPES and select Administrator under BOT PERMISSIONS GENERAL PERMISSIONS.GENERATED URL at the bottom of the page and paste this link into your web browsers address bar.Manage Server or Administrator permission.Copy User ID as shown below:
Copy Server ID as shown below:
Create Project button at the bottom of the settings list as shown below:Create button.API keys page above the settings page on the left side navigation pannel. Alternatively you can click Here.Create new secret key button.You under Owned by. Name your API key something descriptive and select the new project you just created in the Project dropdown. Set Permissions as All and click the Create secret key button as shown below:
Credit balance:Ensure you have an available Credit balance. You can check on the Billing page in Settings or by clicking Here. If you do not have a Credit balance you will need to add money (credit) to your account otherwise this discord bot's chat GPT functionality will not work.
No - it is a Discord bot that needs discord.py, network access, and the OpenAI API.