A Discord BOT Powered By OpenAI's ChatGPT.
This BOT uses ChatGPT API & Firebase Firestore Database.
π₯ Use slash command /ask to ask questions in any channel.
π Direct Message (DM) the bot to get answer / response privately (switchable).
π§΅ Continue Conversation in DM or using /ask
π Use /reset-chat to Start a new Conversation / Thread.
π₯ Uses Firestore Database for persistent chat history storage & logs.
β¨ Chalk, Figlet & Gradient-String for decoration.
π« Easy Setup !
-
DM- Ask Anything. -
/ask- Ask Anything. -
/help- Get Help. -
/ping- Check Websocket Heartbeat && Roundtrip Latency. -
/reset-chat- Start A Fresh Chat Session/Thread.
- Git
- Node.js v18
- OpenAI Account
- Discord Account
- Google Account For Firebase
- Atleast 1vCPU , 0.25GB RAM & 0.5GB Storage for the Bot.
-
Create New Application (BOT) from Discord Developer Portal and add this to your Discord Server with:
Scopes:bot&application.commands
Bot Permissions:2734284602433
Privileged Gateway Intents:PRESENCE,SERVER MEMBERS,MESSAGE CONTENT -
Starβthis Repo to get updates. -
Clone this repo:
git clone https://github.com/itskdhere/ChatGPT-Discord-BOTThen navigate to the folder:
cd ChatGPT-Discord-BOT- Install all dependencies:
npm install-
To setup Environment Variables, Create a
.envfile in the root directory or Rename the.env.examplefile to.env
Then, fill the credentials properly by following this instruction. -
Setup Firebase Firestore Database by following this instruction.
-
Start the BOT:
npm run startOr, During Development:
npm run devOr, In Production:
npm run prod- Use the BOT π
-
DISCORD_CLIENT_ID- Client ID of the bot from OAuth2 section. -
DISCORD_BOT_TOKEN- Token of the bot from Bot section. -
DIRECT_MESSAGES- true/false -
DM_WHITELIST_ID=[ "id_1" , "id_2" ]- Set Discord user IDs of users only who can use bot from dm. You can add as many as you want in proper format. -
OPENAI_API_KEY- Get OpenAI API Key from here. -
DISCORD_MAX_RESPONSE_LENGTH- Max 2000 , recomended 1900. -
API_ENDPOINT- Setdefaultfor api.openai.com endpoint. But you can set 3rd party equivalent endpoint too. -
DEBUG- true/false -
UWU- true/false
See .env.example file for more details
-
Goto Firebase Console: console.firebase.google.com (No Card Required)
-
Click on
Create a projectorAdd project. Give it a name and clickContinue -
Disable Google Analytics & Click
Create Project -
From the side-bar goto
Build& thenFirestore Database. -
Click
Create Database -
Select
Start in production mode& clickNext -
Select a Firestore location nearest to your Server / VPS. This'll also set the Default GCP Resource Location & you can't change it later.
Then clickEnable -
Now goto
Project settings&Service accounts. -
Under
Firebase Admin SDKselectNode.js. Then clickGenerate new private keyand then clickGenerate key -
Important: Rename the downloaded json file to
firebaseServiceAccountKey.json
Any other name will not work here. Then put the json file in your bots directory.
Copy FileName:
firebaseServiceAccountKey.json⨠Tip: check out these images here
π License: MIT
π ChatGPT API: transitive-bullshit/chatgpt-api
π Database: Firestore
π BaaS: Firebase
β IaaS: Google Cloud Platform
--- π ---