Discord bot written in Golang that interacts with the ChatGPT API.
/chat
command to send a message to the bot in public channels, and it will respond with aTo run this bot, please follow these steps:
Go to the releases page and download the binary that
matches your operating system. Extract the binary to a directory of your choice (such as ~/go-chatgpt-discord
).
In the same directory as the binary, create a copy of env.example
and name it .env
Fill in the appropriate
credentials as directed.
Obtain a new OpenAI API key by following the link here. Then, fill
in OPENAI_API_KEY
.
Set up your Discord application and add a bot from the Discord Developer Portal:
DISCORD_BOT_TOKEN
with your Discord bot token from the Bot settings page.DISCORD_CLIENT_ID
.Check that the installation worked: chmod +x go-chatgpt-discord && ./go-chatgpt-discord
Run the bot by executing ./go-chatgpt-discord
. A bot invitation URL will appear in the console. Copy and paste this
URL into your web browser to add the bot to your server.
Enable direct messages from other members of your server by going to the "Privacy Settings" page of your server and enabling "Allow direct messages from server members".
You're all set! You can now use the bot in your server by typing /chat
in any channel, or by sending a direct
message to the bot.
# build a go binary
$ make
# for local development
$ make run
# run unit tests
$ make test
Welcome any kind of contribution to this repository. If you have any suggestions or ideas for improving the code examples or best practices, please feel free to open an issue or submit a pull request.
Distributed under the MIT License. See LICENSE
for more information.