Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rayspock/go-chatgpt-discord

Discord bot written in Golang that interacts with the ChatGPT API
https://github.com/rayspock/go-chatgpt-discord

ai bot chatgpt discord discord-bot go golang

Last synced: about 1 month ago
JSON representation

Discord bot written in Golang that interacts with the ChatGPT API

Awesome Lists containing this project

README

        

[![GitHub Release](https://img.shields.io/github/release/rayspock/go-chatgpt-discord.svg?style=flat)]()
[![Github All Releases](https://img.shields.io/github/downloads/rayspock/go-chatgpt-discord/total.svg?style=flat)]()
# ChatGPT Discord Bot

Discord bot written in Golang that interacts with the ChatGPT API.

![go-chatgpt-discord-slash-command-demo](https://github.com/rayspock/go-chatgpt-discord/assets/19812545/28bc4608-871f-4477-bbb4-fcfbbdbe9a27)

![go-chatgpt-discord-direct-message-demo](https://github.com/rayspock/go-chatgpt-discord/assets/19812545/9e2b17bc-b104-4250-87e2-7f5b5886711d)

## Table of Contents

- [Features](#features)
- [Installation](#installation)
- [Local Development](#local-development)
- [Contributing](#contributing)
- [License](#license)

## Features

- [x] **[Slash Command]**
- Use `/chat` command to send a message to the bot in public channels, and it will respond with a
message generated
by the ChatGPT API.
- [x] **[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.

## Installation

To run this bot, please follow these steps:

1. Go to the [releases page](https://github.com/rayspock/go-chatgpt-discord/releases) and download the binary that
matches your operating system. Extract the binary to a directory of your choice (such as `~/go-chatgpt-discord`).
1. In the same directory as the binary, create a copy of `env.example` and name it `.env` Fill in the appropriate
credentials as directed.
1. Obtain a new OpenAI API key by following the link [here](https://platform.openai.com/account/api-keys). Then, fill
in `OPENAI_API_KEY`.
1. Set up your Discord application and add a bot from
the [Discord Developer Portal](https://discord.com/developers/applications):

- Fill out `DISCORD_BOT_TOKEN` with your Discord bot token from the Bot settings page.
- Copy your "Client ID" from the OAuth2 tab and fill in `DISCORD_CLIENT_ID`.

1. Check that the installation worked: `chmod +x go-chatgpt-discord && ./go-chatgpt-discord`
1. 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.
1. 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".
1. 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.

## Local Development

```shell
# build a go binary
$ make

# for local development
$ make run

# run unit tests
$ make test
```

## Contributing

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.

## License

Distributed under the MIT License. See `LICENSE` for more information.