Giter Club home page Giter Club logo

chatgpt-discord-bot's Introduction

ChatGPT Discord Bot

Build your own Discord bot using ChatGPT


Warning

2023-02-10 Update: ChatGPT model but requires payment

2023-02-08 Update: ChatGPT API is highly unstable now

2023-02-03 Update: ChatGPT API working again

2023-02-02 Update: OpenAI has closed ChatGPT API, temporarily switching to using GPT-3 model

2023-02-01 Update: Now using the official ChatGPT API

Features

  • /chat [message] Chat with ChatGPT!
  • /private ChatGPT switch to private mode
  • /public ChatGPT switch to public mode
  • /replyall ChatGPT switch between replyall mode and default mode
  • /reset Clear ChatGPT conversation history

Chat

image

Mode

  • public mode (default) the bot directly reply on the channel

    image

  • private mode the bot's reply can only be seen by the person who used the command

    image

  • replyall mode the bot will reply to all messages in the server without using slash commands

    Warning The bot will easily be triggered in replyall mode, which could cause program failures

Setup

Install

  1. pip install -r requirements.txt
  2. Rename the file .env.dev to .env

Step 1: Create a Discord bot

  1. Go to https://discord.com/developers/applications create an application

  2. Build a Discord bot under the application

  3. Get the token from bot setting

    image

  4. Store the token to .env under the DISCORD_BOT_TOKEN

    image

  5. Turn MESSAGE CONTENT INTENT ON

    image

  6. Invite your bot to your server via OAuth2 URL Generator

    image

Step 2: Generate a OpenAI API key

  1. Go to https://beta.openai.com/account/api-keys

  2. Click Create new secret key

    image

  3. Store the SECRET KEY to .env under the OPENAI_KEY

Step 3: Run the bot on the desktop

  1. Open a terminal or command prompt
  2. Navigate to the directory where you installed the ChatGPT Discord bot
  3. Run python3 main.py to start the bot

Step 3: Run the bot with Docker

  1. Build the Docker image & Run the Docker container docker compose up -d

  2. Inspect whether the bot works well docker logs -t chatgpt-discord-bot

    Stop the bot:

    • docker ps to see the list of running services
    • docker stop <BOT CONTAINER ID> to stop the running bot

Have a good chat!

Optional: Setup starting prompt

  • A starting prompt would be invoked when the bot is first started or reset

  • You can set it up by modifying the content in starting-prompt.txt

  • All the text in the file will be fired as a prompt to the bot

  • Get the first message from ChatGPT in your discord channel!

    1. Right-click the channel you want to recieve the message, Copy ID

      channel-id

    2. paste it into .env under DISCORD_CHANNEL_ID

chatgpt-discord-bot's People

Contributors

zero6992 avatar ja1e0 avatar jacky-chay avatar mohamedal-nassirat avatar cnrpman avatar ziipzaaapm16a4 avatar devarxify avatar dovarfalcone avatar bradly0cjw avatar prevailugah avatar jeanhadrien avatar

Stargazers

Ethan Roche avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.