Discord bot written in Golang that interacts with the ChatGPT API.
- [Slash Command]
- Use
/chatcommand to send a message to the bot in public channels, and it will respond with a message generated by the ChatGPT API.
- Use
- [Direct Message]
- Send private messages to the bot, and it will respond with a message generated by the ChatGPT API. This is useful for users who want to interact with the bot without broadcasting their messages to the whole server.
- The responses generated by ChatGPT are streamed in real time so that users can see the progress of the completion. This is particularly useful for chat applications in which the user doesn't have to wait for a long time to see the result.
To 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.exampleand name it.envFill 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:
- Fill out
DISCORD_BOT_TOKENwith your Discord bot token from the Bot settings page. - Copy your "Client ID" from the OAuth2 tab and fill in
DISCORD_CLIENT_ID.
- Fill out
-
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
/chatin 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 testWelcome 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.

