Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Setup guide

ZeroTwoReallyLovesLollipop edited this page Oct 7, 2023 · 13 revisions

Discord and OpenAI setup

Discord setup

  1. You need a Discord account, then you have to access to the Discord Developer Portal

  2. Then you will need to create a new application, you must give it a name, but you can change the name later

  3. Now in the Bot menu you will click Add Bot, there you can select an icon for the bot or change it username, after this you will click View Token, this token its your secret token to get access via the API, you must save this Token and you shouldn't share it publicly

  4. Then in the OAuth2 submenu you must search for the URL Generator submenu, there you will need the permissions required for you app, the you will need to check "bot" and "applications.commands", then when you check those option you will get a new window called "BOT PERMISSIONS", in this windows you have to check the permissions, if you are going to edit the code of the bot and add other features you must check which permissions would be required and check it at this point, the minimum permissions are:

    • Read Messages/View Channels
    • Send Messages
    • Send TTS Messages
    • Embed Links
    • Attach Files
  5. After checking the permissions you will have a discord link, this discord will allow you to associate your discord bot with your discord server, paste that link into your browser and add your bot into the server where you are going to test it

OpenAI setup

  1. Now it's time to create an OpenAI API Key, to do this you should have an OpenAI Developer Account, then in the View API Keys you can create a new secret key, you must save this secret key and you shouldn't share it publicly

Python and repository setup

Easy method (Replit)

  1. Create a new replit and clone this repository or fork this Replit

  2. Create a copy of example_config.yml and rename it as config.yml open it and configure the bot (A full guide of the config file can be found here):

bot:
  token: "YOUR_DISCORD_KEY" # Paste here the token you got from Discord Developer Portal
  use_audio: False

open_ai:
  token: "YOUR_OPEN_AI_KEY" # Paste here the OpenAI secret key you got from OpenAI platform
  role: "You are a helpful assistant." # Change here chatbot's role, this will change it's behavior answering questions

  1. Now press Run, the first time the Replit execute the poetry package manager will install the required libraries so it will take a while

  2. Now check in your Discord server using the command

your_prefix.hello

Local Windows method

  1. Install Python 3.9.16 using the Python page

  2. Clone the repository, you can either download the repository as a .zip and unzip, or clone the repository using git:

git clone https://github.com/02loveslollipop/DiscordGPTChatBot.git
  1. Install FFmpeg:
winget install ffmpeg
  1. Create a copy of example_config.yml and rename it as config.yml open it and configure the bot (A full guide of the config file can be found here):
bot:
  token: "YOUR_DISCORD_KEY" # Paste here the token you got from Discord Developer Portal

open_ai:
  token: "YOUR_OPEN_AI_KEY" # Paste here the OpenAI secret key you got from OpenAI platform
  role: "You are a helpful assistant." # Change here chatbot's role, this will change it's behavior answering questions
  1. Now in the root of the repository execute this command to update all the required libraries:
pip -r requirements.txt
  1. Then execute the python script in the root of the repository:
python main.py
  1. Now check in your Discord server using the command
your_call_sign.hello

Ubuntu setup (ADVANCE)

  1. Install Python 3.9 in the Ubuntu instance, as this isn't the last release we are going to get it from the deadsnakes PPA:
sudo apt update
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa 
sudo apt install python3.9 -y
sudo apt install python3-pip -y
sudo apt install ffmpeg -y
  1. Then we are going to check if we installed the correct version, it should say Python 3.9.xx

  2. Clone the repository:

git clone https://github.com/02loveslollipop/DiscordGPTChatBot.git
  1. Create a copy of example_config.yml and rename it as config.yml:
cp example_config.yml config.yml
  1. Open config.yml and configure the bot (A full guide of the config file can be found here):
bot:
  token: "YOUR_DISCORD_KEY" # Paste here the token you got from Discord Developer Portal

open_ai:
  token: "YOUR_OPEN_AI_KEY" # Paste here the OpenAI secret key you got from OpenAI platform
  role: "You are a helpful assistant." # Change here chatbot's role, this will change it's behavior answering questions
  1. Now execute this command to update all the required libraries:
sudo su
pip install -r /path/to/your/repo/requirements.txt
exit
  1. After that let's create a service so every time the system reboot it starts again the script:
sudo nano /etc/systemd/system/discord.service
  1. In the file write this script, and then save it:
[Unit]
Description=Discord bot service
After=multi-user.target

[Service]
User=root
Type=simple
WorkingDirectory=/home/CHANGE_TO_YOUR_USER/DiscordGPTChatBot/
ExecStart=/usr/bin/python3 main.py

[Install]
WantedBy=multi-user.target
  1. Reload the Systemd daemon to recognize the new service:
sudo systemctl daemon-reload
  1. Enable the service:
sudo systemctl enable discord.service
  1. Start the service:
sudo systemctl start dicord.service
  1. Now check in your Discord server using the command
your_call_sign.hello

Clone this wiki locally