Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord GPT Bot

This is all of the source code of the Discord GPT (OpenAi) bot using Javascript, NodeJS, and ChatGPT to connect and fetch data from the API of ChatGPT. You can type anything to ask the bot in chat and the bot will reply

⁉️ Requirement

To use the bot, you need to have all of the necessary tools below.

🛠 Installation

First step, install some of the JavaScript libraries by type code below in your terminal, command prompt

npm install openai discord.js dotenv

Next step, download all of the code above and open folder it in your code editors to edit something in code such as bot token, OpenAi API key.

.ENV

Change file name to .env and paste the API key and token and replace "Paste your API key here" and "Paste your bot token here" which you can get from above.

OPENAI_API_KEY=Paste your API key here
DISCORD_BOT_TOKEN=Paste your bot token here

index.js

Paste the channel id in your server which you want this bot working only that channel but if you want it work for all channel, place replace the code that you see here

 if (message.channel.id === 'INPUT_YOUR_CHANNEL_ID') {
   message.reply(gptResponse.data.choices[0].text.substring(0));
   console.log('Answer Reply!');
   prompt += `${gptResponse.data.choices[0].text}\n`;
 } else {
   prompt += `${gptResponse.data.choices[0].text}\n`;
 }

with this one below

 message.reply(gptResponse.data.choices[0].text.substring(0));
 console.log('Answer Reply!');
 prompt += `${gptResponse.data.choices[0].text}\n`;

After all environments are set, this is finish installation now

🖥 Usages

Open terminal, command prompt and get in to the floder that you download (unzip file first) by

cd Downloads/Discord-GPT-Bot-main

or type command in terminal by

git clone https://github.com/Billy19191/Discord-GPT-Bot.git

After get inside the floder, run the code to start the NodeJS and your discord bot by

node index.js

if you code working properly, it will showing message in terminal Bot Start & Login Successful! and your bot will be online in the Discord.

About

This is all of source code of Discord GPT (OpenAi) bot with a simply manage and setting!.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages