Code Monkey home page Code Monkey logo

discord-bot-chatgpt's Introduction

Discord GPT

This is a very simple Discord bot that will use the OpenAI API, to be able to query and recieve very useful information like you would in ChatGPT.

You can invite my bot to your server using the following link:
https://discord.com/api/oauth2/authorize?client_id=1062788328224735252&permissions=3072&scope=bot

TRIGGER_MESSAGE : !invoker

Why i decide to create this bot

Firstly, I dont wanna have to reconnect to https://chat.openai.com/chat when my session expire, in discord i dont have to reconnect.

Secundly, I wanna use the bot where ever i am, when i dont have wifi, discordapp in my phone is very good to save mobile data, instead of open the website in a mobile navigator.

That why i create a discord bot using openAI.

What is ChatGPT?

ChatGPT is a chatbot web application written by the developers at OpenAI to be used in conjunction with their own API that uses GPT-3's neural network of deep learning.

Setup and create your own bot

Clone project

clone this project in your local machine

git clone [email protected]:AndrianinaH/discord-bot-chatgpt.git

or

git clone https://github.com/AndrianinaH/discord-bot-chatgpt.git

Create discord bot

got to https://discord.com/developers/applications

1- create a application

2- go to Bots > create a discord bot and get the DISCORD_BOT_TOKEN

3- always in Bot section :

    - allow Authorization Flow : public bot
    - allow all Privileged Gateway Intents : PRESENCE INTENT and SERVER MEMBERS INTENT and MESSAGE CONTENT INTENT
    - select Bot > select Read messages/View Channels and select Send Messages

4- go to 0Auth2 > URL Generator > select Bot > select Read messages/View Channels and select Send Messages

Get your OPENAI_API_KEY

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

invite your bot in discord

First you have to invite your bot in your discord server by following the link you generate previously from the 0Auth2 section in https://discord.com/developers/applications

Run the server bot in your localhost

.env

create a .env following the .env_example

1- use your credentials DISCORD_BOT_TOKEN and OPENAI_API_KEY

2- TRIGGER_MESSAGE :

  • its your custom message to trigger the bot in a discord channel. For my bot, i use !invoker

  • You can use what ever you want here to trigger the bot.

  • Example : !bot donne moi la liste de tous les films du studio Ghibli

install package

run yarn install or npm install

start the bot server localy

run yarn start your bot is now online in your discord server where you have invite him

Run the server bot online

create a github repo where you gonna push your code

hosting

I use https://railway.app/ to host the bot server and keep him always online

  • create a application and follow the step where you have to connect your github repo to railway

  • clic in the application

  • Variables > add the variables from your .env

  • Settings > Deploy > start command add yarn start or npm start

Now after every push you do to your github repo in the specify git branch (default master) your bot server rebuild and restart automatically

discord-bot-chatgpt's People

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.