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
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.
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.
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
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
go to https://beta.openai.com/account/api-keys
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
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
run yarn install
or npm install
run yarn start
your bot is now online in your discord server where you have invite him
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
ornpm 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