Giter Site home page Giter Site logo

billy19191 / discord-gpt-bot Goto Github PK

View Code? Open in Web Editor NEW
32.0 1.0 8.0 28 KB

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

License: MIT License

JavaScript 93.74% Shell 6.26%
dailybot github github-campus-experts github-codespaces learn

discord-gpt-bot's Introduction

Discord GPT Bot

This is all of the source code for 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.

⁉️ Requirements

To use the bot, you'll need to have all of the necessary tools below installed

You'll need to have two tokens from OpenAI and Discord

  • OpenAI (ChatGPT) - Get the API token for your OpenAI account here
  • Discord Developer Portal - Create a bot and get the token here

🛠 Installation

First, install the required JavaScript libraries by pasting code below in your terminal or command prompt.

npm install openai discord.js dotenv

Next step, download all of the code as a .zip file and open it in your code editor of choise to put your own bot token and OpenAI API key.

You may also run git clone, if you have git installed

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

.ENV file

File name must be .env, paste the API key and your Discord bot token by replacing the "Paste your API key here" and "Paste your bot token here"

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 to be working only in that channel, if you want it work for all channel, 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, installation is finished!

🖥 Usage

Start a terminal session, then cd into the project

cd ./Discord-GPT-Bot/

Run the index.js file using node

node index.js

If you did everything correctly, the script should be working properly, a message will show up in the terminal: Bot Start & Login Successful!

Your bot is now online on Discord.

🖥 Example

Screenshot 2023-01-10 at 16 44 35

discord-gpt-bot's People

Contributors

billy19191 avatar maguswyvern avatar maksikos-ctrl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.