Code Monkey home page Code Monkey logo

itzarshia / gpt-discord-bot Goto Github PK

View Code? Open in Web Editor NEW
232.0 8.0 57.0 3.67 MB

🧠 Example Discord Bot written in JavaScript that uses OpenAIs models such as ,`GPT 4`, `GPT-3.5-Turbo`, `Dall-E`, and `Text-Moderation-Stable` with many features such as ChatGPT-Style Conversation, image-Generator, Auto-Moderator and more!

License: MIT License

JavaScript 100.00%
ai bot chatbot openai translator discord image-generator moderation chatgpt dall-e

gpt-discord-bot's Introduction

Chat GPT Discord Bot

GPT Discord Bot is the original Discord AI bot written in JavaScript, using the Discord.js V14 library powered by OpenAI's models. It has different features such as answering all of your questions or drawing your imagination and even translating your prompts from any language to any other language you want and also has a configurable Auto Moderation system powered by AI which watches all of your server messages (if you want, you can turn it off/on) and report flagged messages to Admins and they can moderate it and other features which you can see example in Screenshots!

🚧 Requirements

  1. Discord Bot Token Guide
    1.1. Enable "Message Content Intent" and "Server Members Intent" in Discord Developer Portal
  2. OpenAI API Key
  3. Node.js 16.9.0 or higher

🚀 Getting Started

⚙️ Configuration

Go to config.json in the configs folder and fill out the values:

{
    "Prefix": "Put anything you want as a prefix",
    "MainColor": "Put any #HexCode you want for embeds color",
    "ErrorColor": "Put any #HexCode you want for embeds color when there is an error",
    "ClientID": "Put your Bot ID/Client ID here",
    "Token": "Put your Bot Token here",
    "OpenAIapiKey": "Put your Open AI API Key here"
}

⚠️ Note: Never commit or share your token publicly ⚠️

and if you want to use the chatbot or moderation model fill and config chatbot.js and moderation.js in the configs folder (Information on how to configure them is available in the files themselves)

🧠 installation

Open your terminal and install the required packages with

npm install

After installation finishes run node register.js to deploy slash commands and then run node index.js in the terminal to start the bot.

💫 Features

Commands

Ask : Answers your questions with all GPT models (GPT-3.5-Turbo & GPT-4.0)!

Imagine : Draw your imaginations with Dall∙E!

Optimize : Optimizes your imaginations to get a better response with the imagine command with GPT-3.5-Turbo!

Translate : Translate your texts in any language to any language you want with GPT-3.5-Turbo.

Systems

ChatBot : A Channel where you can talk to the bot and have ChatGPT-Style conversation with GPT-3.5-Turbo. (It has a temporary memory so that it can remember the contents for a short time)

Auto-Moderation : An Auto Mod system that checks all of your server messages and sends a log for your Admins if a message content complies with OpenAI's usage policies with Text-Moderation-Stable (moderation model is free to use and you can config it as much as you want)

📸 Screenshots

Ask imagine Translate Conversation Auto Mod

❤️ Donations

You can support me by donating if you like the project!

Only available for Iranians :(

Made with ❤️ and JavaScript, Don't Forget to ⭐

gpt-discord-bot's People

Contributors

itzarshia avatar kav-k 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpt-discord-bot's Issues

help

Error: Cannot find module './configs/config.json'
Require stack:

  • C:\Users\Revoltz\Desktop\GPT 3.5\register.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object. (C:\Users\Revoltz\Desktop\GPT 3.5\register.js:4:16)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ 'C:\Users\Revoltz\Desktop\GPT 3.5\register.js' ]
    }

Outdated Description

An update released for this repository recently due to openai added GPT 3.5 to their API. The current description is outdated mentioning text-davinci instead of GPT-3.5-Turbo.

Message commands reply twice on chatbot mode

When I turn on chatbot mode on a certain channel, bot will reply to message command twice. Specially the first reply comes from chatbot event and second from its related message command event. My solution is to bypass message commands on the channel which chatbot is on. But to modify chatbot event listener may be a more decent way.

const { chatbot } = require('../../configs/chatbot');

//add to execute 
if (chatbot.State && chatbot.ChatBotChannel === message.channelId && !chatbot.IgnoredUsers.includes(message.author.id)) 
    return

Setup

Add setup cmd or you can also do in config.js a specific channel ID then bot can answer in this channel

Time/Date is Displayed Wrong

When asked for today's date, the bot asked for what timezone (Which is normal) but then posted the exact message:

"In Pacific Daylight Time (PDT), today's date is: {{moment().tz('America/Los_Angeles').format('dddd, MMMM Do YYYY')}}."

Showing the code for the time rather than properly formatting

Error: Request failed with status code 400

After I send /ask question

Error: Request failed with status code 400
[antiCrash] :: Unhandled Rejection/Catch
TypeError: Cannot read properties of null (reading 'length')
    at F:\GPT-Discord-Bot-main\commands\interactions\ask.js:80:40
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.execute (F:\GPT-Discord-Bot-main\commands\interactions\ask.js:71:28) Promise {
  <rejected> TypeError: Cannot read properties of null (reading 'length')
      at F:\GPT-Discord-Bot-main\commands\interactions\ask.js:80:40
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async Object.execute (F:\GPT-Discord-Bot-main\commands\interactions\ask.js:71:28)
}

TypeError: openAI.Configuration is not a constructor

Hello, i just got this error " TypeError: openAI.Configuration is not a constructor " when i use the command !ask [MY MESSAGE]

I don't know how to fix this problem, someone told me about changing the code but i don't what to change.

Thanks in advance.

GPT-4 Turbo

How can I enable the GPT -4 turbo to be used as the response engine?

Database?

Would it be possible to have this set up to accept a pinecone API key so i can expand its memory>?

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.