Integrate ChatGPT with Discord: Easy No-code Method

How to integrate ChatGPT with Discord
Reading Time: 6 minutes

ChatGPT is everywhere. It can be integrated into WhatsApp and let it reply to messages on your behalf; or you can chat with it from WhatsApp and even generate images. Or if you a more of a Telegram person, then you can integrate ChatGPT with Telegram by turning it into a bot.

But apparently, ChatGPT is not in your Discord—at least not yet. But in a few moments, you’ll be able to integrate ChatGPT with Discord and add ChatGPT to Discord and have it in your Discord, too.

The way to integrate ChatGPT into Discord is to create a ChatGPT Discord bot and add it to your server. The bot will respond to you command and return with answers.

After you’ve integrated ChatGPT into Discord, you can use ChatGPT in Discord. No need to switch between apps or tabs; you can have it all within Discord.

Using ChatGPT in Discord - Integrate ChatGPT with Discord

You can even generate AI images with the ChatGPT Discord bot. And not just that, there are different personas pre-built into it so that you can easily get the most rogue and unfiltered version of ChatGPT, should you want it.

ChatGPT image generation - Integrate ChatGPT with Discord

But, we’re getting ahead of ourselves. Before you integrate ChatGPT with Discord and add a ChatGPT bot in Discord, there are a few things you’ll need.

Prerequisites to integrate ChatGPT with Discord

Before you can create a Chatgpt Discord bot, and integrate ChatGPT with Discord, you’ll need the following.

  • Python (3.10 or later)
  • OpenAI API key
  • Discord bot token

Installing Python

If you don’t have Python installed on your computer, download the latest version from here and install it.

If you are using Linux, you can install directly using this command:

sudo apt install python3

After you’ve installed it, check the version by running the following command

python3 --version

Getting OpenAI API key

An OpenAI API key is not in fact a prerequisite, but using it to authenticate will ensure that the ChatGPT Discord bot works flawlessly. 

Obtain an API key from OpenAI. The API key can be found in the Use Settings.

OpenAI API key - Integrate ChatGPT into Discord

If you don’t have the secret key saved or don’t have it yet, you can create a new one by clicking the “+ Create new secret key” button. Keep the key safe and confidential; the key will not be displayed again.

Note that the API is not free. So unless you have some free credits, you need to upgrade to a paid plan by setting up a payment method.

Creating a Discord bot

Go to https://discord.com/developers/applications and click “New Application”.

Creating a new application in Discord - How to integrate ChatGPT into Discord

Give the application a name, check the terms of service, then click “Create”.

Name the Discord application - How to integrate ChatGPT with Discord

Click “Bot” on the left panel. Then click the “Add Bot” button.

Adding a Discord bot - Integrate ChatGPT with Discord

Name your bot and then click the “View Token” button to uncover your Discord bot token. Or simply click the “Copy” button to copy it. Keep this token somewhere safe. It will be used later on to add ChatGPT to Discord.

Discord bot token

Click “OAuth2” on the left panel and select “URL Generator”. Then select the scopes. Make sure to select the “bot” option.

Generating bot URL

Give the necessary permissions to the bot. A unique URL will be generated for the selected permissions. Copy the URL.

Discord bot URL - Integrating ChatGPT bot in Discord

Open a new tab and paste the URL. Select the Discord server to which you want to add the ChatGPT bot. Then click “Continue”.

Add ChatGPT to Discord - How to integrate ChatGPT with Discord

If you are not the owner of any server, then create one. And then add the ChatGPT bot to your Discord server.

Integrating ChatGPT into Discord will now be a piece of cake. Follow the instructions below to integrate ChatGPT into your Discord server.

How to integrate ChatGPT with Discord

We can now begin to integrate ChatGPT into Discord. Below is a step-by-step guide on how to integrate ChatGPT with Discord.

1. Clone this repository on GitHub. Click the “Code” button and then “Download ZIP” to save the file on your computer.

2. Unzip the file, chatGPT-discord-bot-main.zip.

3. Open Command Prompt or Terminal and navigate to the unzipped folder (chatGPT-discord-bot-main). Or you can open the folder and launch Command Prompt or Terminal from there by right-clicking and selecting the option.

4. Run the following command to install the required packages.

pip3 install -r requirements.txt

5. Open the .env.dev file in the unzipped folder and enter your Discord bot token and the OpenAI API key.

Integrating ChatGPT into Discord

Alternatively, you may use your session token and OpenAI login email and password to pass the authentication instead of the API key. This method is not guaranteed to work but if you don’t have an OpenAI API key or have run out of credits, you can use this method.

6. Save the file and rename it to .env

7. Run the following command from the root directory to start the ChatGPT Discord bot.

python3 main.py

If all goes well, you should see a status that says your Discord bot is running.

Running ChatGPT Discord bot

And so that’s how we can easily integrate ChatGPT with Discord and add ChatGPT to Discord. You can now chat with ChatGPT from Discord. Don’t forget to start your prompt with /chat to summon the ChatGPT Discord bot.

ChatGPT Discord bot

The ChatGPT Discord bot will respond in a few seconds with the answer.

Using ChatGPT in Discord

If you want to generate images with the ChatGPT Discord bot, use the /draw command before your prompt.

Generating AI images with ChatGPT Discord bot

There a several other fun as well as useful things that you can do with the ChatGPT bot in Discord. In the section below, you’ll find the ways to use the various features of the ChatGPT bot in Discord.

How to use ChatGPT in Discord

After you’ve integrated ChatGPT with Discord and added the ChatGPT Discord bot to your server, you’ll be able to chat and interact with ChatGPT as you would on chat.openai.com. You also get enhanced functionality such as the ability to generate images and ready accessibility of multiple personas.

Switch command to change bot personas

Here’s how you can use ChatGPT in Discord.

  • To chat with ChatGPT on Discord, use the command /chat and followed by the prompt. Example: /chat Who was the first first lady of the US?
  • To generate an image from text, use the /draw command followed by your prompt.
  • To switch personas, use the /switchpersona command and select one of the personas from the options.
Different personas of the ChatGPT Discord bot
  • To switch to a private mode use /private command.

There are some other modes and features. You can find them here.

Some recommended articles

How to Use ChatGPT for Coding to Maximise Your Coding Potential

How to Use ChatGPT to Master Excel and Google Sheets

How to Use ChatGPT for learning English

16 responses to “Integrate ChatGPT with Discord: Easy No-code Method”

  1. I followed each steps and all worked for me expect running ‘python3 main.py’ command. Nothing happened when I run it. How could I solve this problem?

    • What is the command prompt or terminal response that you got? Did you run the command from the parent directory of the Discord bot file? Without more detail I cannot help you solve the issue.

  2. “Open Command Prompt or Terminal and navigate to the unzipped folder (chatGPT-discord-bot-main). Or you can open the folder and launch Command Prompt or Terminal from there by right-clicking and selecting the option.”

    That doesn’t work. You can’t right click on the folder and open it with command prompt. I’m very, very confused. Also typing this”pip3 install -r requirements.txt” into the the command prompt with admin privileges gives me a syntax error, the same with python3. What am I supposed to type that command in? You went from telling me how to create the bot on Discord to tying in commands, but where? Python? The Command Prompt? I have no idea where I’m supposed to type this. I have an VM running Linux and Command Prompt at the ready for this command.

    • I’m not quite sure what issues you’re facing and why.

      Unzip the Discord bot file you’ve downloaded, open it. Then right-click anywhere and select “Open command window from here” and then run the command. You have to do the same to re-activate the bot.

    • You can just open it with any text editor. There are no special programs to open the file. Double click file and open with any text editor you have on your computer.

    • That may be because the file is hidden. Make sure that hidden files are displayed. The way to make hidden files visible differs from operating system to system.

  3. Hello, I did everything as indicated in the guide and an error came out

    Traceback (most recent call last):
    File “d:\chatGPT-discord-bot-1.3.1\main.py”, line 1, in
    from src import bot
    File “d:\chatGPT-discord-bot-1.3.1\src\bot.py”, line 5, in
    from src.aclient import client
    File “d:\chatGPT-discord-bot-1.3.1\src\aclient.py”, line 162, in
    client = aclient()
    File “d:\chatGPT-discord-bot-1.3.1\src\aclient.py”, line 40, in __init__
    self.chatbot = self.get_chatbot_model()
    File “d:\chatGPT-discord-bot-1.3.1\src\aclient.py”, line 47, in get_chatbot_model
    return Chatbot(api_key=self.openAI_API_key, engine=self.openAI_gpt_engine, system_prompt=prompt)
    File “C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\revChatGPT\V3.py”, line 81, in __init__
    self.aclient = httpx.AsyncClient(
    TypeError: AsyncClient.__init__() got an unexpected keyword argument ‘follow_redirects’

    • Hi, the repository has been updated since this tutorial was published. You can go to the GitHub repository and refer to the updated guide. And check the issues (open and closed) to see if others are facing similar problems.

  4. So I’m getting the raise PrivilegedIntentsRequired(exc.shard_id) from None
    discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal.
    It doesn’t say what those intents are, as I’ve enabled all the intents listed? Maybe I’m missing one or something?

    • Hi Mark, I’m not quite sure what the issue is. But make sure that “MESSAGE CONTENT INTENT” is toggled on. You can do that by going to https://discord.com/developers/applications/ and selecting the application. Then select the “Bot” option and switch the toggle.

      You can also refer to the updated guide on the GitHub page as the repository has been updated since this tutorial was published.

  5. same issue here this is the error im getting: ‘Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.’

  6. for those of you having issues with the python commands such as python3 or pip3. When using those commands listed in this article leave the number 3 off the commands and type it like pip or python not pip3 or python3

  7. I have an issue keeping the bot running. Followed the guide and it logged in successfully, and works within Discord, as long as I have the terminal open. Once closed, the bot goes offline. Is there a guide on setting the bot up to automatically log in and stay on, without having to start it via terminal & keeping it open? thanks.

Leave a Reply to thefallenalchemistCancel reply

Discover more from Amigo: No-code Data Integrations to Google Sheets

Subscribe now to keep reading and get access to the full archive.

Continue reading